-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
net/url: add URL.ForceFragment like ForceQuery for empty fragments to stringify with '#' #29603
Comments
/cc @bradfitz |
In your "What did you expect to see?" section, you expected the value of https://golang.org/pkg/net/url/#URL.Fragment Fragment string // fragment for references, without '#' So clearly that can't work as you expect. What we could do perhaps is add |
Right. "What did you expect to see?" is perhaps the wrong phrasing of the question. I'm only arguing that the API has no way to distinguish these two cases. It does look like ForceFragment would be the best API for fixing this. |
@bradfitz so he sees my reply. |
I see all replies and saw yours last week. I just had nothing further to add. We're in the Go 1.12 release freeze right now (https://github.com/golang/go/wiki/Go-Release-Cycle) so this isn't a priority. |
No worries, just wanted to check. Cheers. |
What version of Go are you using (
go version
)?What did you do?
What did you expect to see?
What did you see instead?
What's the issue?
At first glance,
http://example.com/#
andhttp://example.com/
are logically the same URL. This is largely true in the context of a browser navigating to that URL as typed into the URL bar, but they are subtly different in a link. If a user clicks the following link:If the document URL (or
<base href>
) ishttp://example.com/
then this click does not cause a navigation - it is a within document link. However, if the link was instead to:Then clicking it causes a navigation. A reload really, but still a navigation.
This becomes more of an issue when net/url is used to resolve a relative URL:
nav
andlocal
are now equal, which means it's not possible to distinguish a document local link and a navigation link.The text was updated successfully, but these errors were encountered: