-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
Currently url.Parse("#foo") results in an error. It should result in a url.URL
with only the Fragment field set, like when you get the RawQuery field set after calling
url.Parse("?foo").
URIs that include only a fragment are described by the RFC [1]:
The most frequent examples of same-document references are
relative references that are empty or include only the number
sign ("#") separator followed by a fragment identifier.
And of course "#foo" is a valid href value in an HTML document. It gets more
curious: "" is also a same-document reference, so should
url.Parse("") be allowed?
Imagine that for web-scrapping, you define a function that merges the document URL with
the href values it finds. This function can't receive *url.URL as argument, because
url.Parse("#foo") and url.Parse("") both result in error, despite
being meaningful href values.
[1] http://tools.ietf.org/html/rfc3986#section-4.4