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

net/url: clarify in docs that RawPath is not always set by Parse() #29662

clausti opened this issue Jan 10, 2019 · 1 comment


None yet
3 participants
Copy link

commented Jan 10, 2019

The documentation for the URL type states that

The Parse function sets both Path and RawPath in the URL it returns, and URL's String method uses RawPath if it is a valid encoding of Path, by calling the EscapedPath method. [emphasis added]

which makes it sound like it will always be set but this is not the case.

In the parse() function called by Parse() and ParseRequestURI(), a comment states that it sets Path

and, optionally, RawPath. [...] We don't want to set it if the default escaping of Path is equivalent, to help make sure that people don't rely on it in general. [emphasis added]

For example:
Parsing "/foo" sets Path as "/foo" but does not set RawPath.
Parsing "%2Ffoo" sets the same Path, "/foo", but also sets RawPath as "%2Ffoo".

This is unexpected behavior based on the public package documentation, which should be updated.

@dmitshur dmitshur added this to the Go1.13 milestone Apr 24, 2019


This comment has been minimized.

Copy link

commented Apr 24, 2019

/cc @rsc @bradfitz (per net/url owners)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.