-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
- What version of Go are you using (
go version)?
1.6.2 - What operating system and processor architecture are you using (
go env)?
linux amd64 - What did you do?
https://play.golang.org/p/loaa8vvCli
Attempted to use net/url to encode a component of a URI which contained both forward-slashes and whitespace. - What did you expect to see?
A method akin to JSencodeURIcomponentwhich would encode the component the way I need. - What did you see instead?
No solution, as of yet.
I'm interacting with an API where I need to escape individual URI components. In my specific case, I'm escaping components containing whitespace and forward slashes. As demonstrated above, net/url seems to have no method which I can use to accomplish this. Any url.Parse() related function will ignore forward slashes, as it should. I also can't rely on something such as url.QueryParse(), as query string encoding turns whitespace into +.
Would it be possible for net/url to add functionality akin to JS's encodeURIcomponent to cover cases such as this?
ericlagergren