Skip to content
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

Safari turns my go/link URL into a web search #9

Open
vielmetti opened this issue Dec 1, 2022 · 9 comments
Open

Safari turns my go/link URL into a web search #9

vielmetti opened this issue Dec 1, 2022 · 9 comments

Comments

@vielmetti
Copy link
Contributor

System configuration: Safari Version 16.0 (17614.1.25.9.10, 17614), macOS Monterey 12.6 (21G115).

I have set up a "go" endpoint, and when I type "go" into the search / URL entry box, it properly sends me to the "go" endpoint on my talent.

I have a link defined, go/gmail . It's listed as a "popular link", and when I click on it it does the expected thing and redirects.

However.

If I type go/gmail into the URL entry box at the top, the system misinterprets go/gmail as a search string, and puts me on a Google search results page.

The issue appears to be "Safari ignores local domain" - https://discussions.apple.com/thread/5504425 - and the suggested workaround (ick) is to either use a fully qualified domain name, or use the http:// prefix. (Or, probably, use Chrome.)

@willnorris
Copy link
Member

Chrome does that as well sometimes, but it seems to "learn" that "go" is a valid hostname after a few successful resolutions. That doesn't seem to be working with Safari :(

However, including a trailing slash does seem to work in Safari... does go/gmail/ work for you?

@vielmetti
Copy link
Contributor Author

The trailing / does help! All of the simple mappings I set up seem to work.

The more complicated ones are, of course, more complicated. From go/.help this query for Google:

https://www.google.com/{{if .Path}}search?q={{QueryEscape .Path}}{{end}}

if I hit go/search/foo it never hits the golink rewriter, and if I hit go/search/foo/ it properly routes through golink but searches for "foo/" instead of "foo".

(is there a way to truncate the last character of a string in the template language if that last character is a / ?)

@willnorris
Copy link
Member

willnorris commented Dec 1, 2022

not currently. I suppose we could expose strings.TrimSuffix, so then you could have something like:

https://www.google.com/{{if .Path}}search?q={{QueryEscape (TrimSuffix .Path "/")}}{{end}}

That's kind of annoying to have to add that to all of your links, though. I wonder if there's a better way that we could handle it automatically 🤔

@willnorris
Copy link
Member

okay, I can't figure out how to reliably reproduce it, but I now have Safari properly resolving go/foo links without the trailing slash. This is Safari 16.1 on macOS 13.0.1. I've closed and reopened Safari a couple of times, which is possibly related? And it certainly seems to work with links I've never opened in Safari before, so it's not just pulling out of a cache. Can you see if you can reproduce that at all? Close and reopen Safari? Maybe stick your tongue out to the side while doing it? 😜

@vielmetti
Copy link
Contributor Author

I closed and reopened Safari, no bueno. But I do have an operating system upgrade to do to get to macOS 13.0.1 from 12.6, so if there's a change to be done that helps with that it's in my future.

PR #10 adds in the TrimSuffix function, so that your example code above works. Agreed that there's certainly some better way to do it, but this gives me at least a working way forward.

@mullender
Copy link
Contributor

This might be solved by #21
that change ads support for keyword search from the url bar in Safari (and the other browsers) in my local testing I was able to type 'localhost' 'test' and it correctly resolved to http://localhost:8080/test and then redirected to the configured url.

@juwoncaleb
Copy link

Hello
Has this issue being fixed?

@j-f1
Copy link

j-f1 commented Mar 1, 2023

After adding the trailing slash (eg go/foo/) I haven’t had any problems.

@noncombatant
Copy link
Contributor

See also #29. cc @awly

patrickod added a commit that referenced this issue Dec 8, 2023
Updates #9

On tailnets with TLS enabled serve HTTP traffic with a separate
redirectHandler which sends requests to our HTTPS listener destination.

Add `-L` to documented examples of using `curl` to follow these
redirects if present.

Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
patrickod added a commit that referenced this issue Dec 18, 2023
golink: listen on HTTPS and redirect HTTP traffic

Updates #9
Fixes #29

On tailnets with HTTPS enabled golink will serve the primary endpoints via
HTTPS. With HTTPS enabled golink will respond to HTTP traffic with a 
separate redirectHandler which redirects requests to their HTTPS equivalent.

Update documented examples of `curl` to include the `-L` flog to follow these
redirects if present. 

Add a HTTPS section to the README documenting all of the above.

Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants