-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add TrimSuffix to the function map #10
Conversation
Adds strings.TrimSuffix to the function map, enabling it to be used in URL definitions.
Would you mind also adding a test case in https://github.com/tailscale/golink/blob/main/golink_test.go ? I'm also happy to add one myself. |
(in those tests, the leftover path is called "remainder". I just never renamed that apparently) |
hmm... I dont' know if I can suggest changes on a file that you didn't already touch, so the additional test case would just be: {
name: "template-with-trimsuffix-func",
long: `http://host.com/{{TrimSuffix .Path "/"}}`,
remainder: "a/",
want: "http://host.com/a",
}, |
As told by @willnorris , this tests the TrimSuffix function.
Test added as requested. |
Awesome, thanks! Looks great. |
Updates #10 Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <[email protected]>
We need TrimPrefix and ToUpper for some links at Tailscale, and might as well ToLower as well at that point. Updates #10 Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <[email protected]>
We need TrimPrefix and ToUpper for some links at Tailscale, and might as well ToLower as well at that point. Updates #10 Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <[email protected]>
We need TrimPrefix and ToUpper for some links at Tailscale, and might as well ToLower as well at that point. Updates #10 Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <[email protected]>
We need TrimPrefix and ToUpper for some links at Tailscale, and might as well ToLower as well at that point. Updates #10 Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <[email protected]>
Adds strings.TrimSuffix to the function map, enabling it to be used in URL definitions.
This accompanies the discussion in #9 and is motivated by the browser misfeature of my Safari instance, which fails to recognize a local domain URL as a URL unless it has a trailing slash. The intended use of this function is to trim that trailing slash.
(There is most certainly some more elegant way to do this, but as a start this is the one-line fix suggested by @willnorris that lets me make forward progress.)