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: No adequate method exists for encoding a URI component #16207

Closed
alienth opened this issue Jun 29, 2016 · 3 comments
Closed

net/url: No adequate method exists for encoding a URI component #16207

alienth opened this issue Jun 29, 2016 · 3 comments
Milestone

Comments

@alienth
Copy link

alienth commented Jun 29, 2016

  1. What version of Go are you using (go version)?
    1.6.2
  2. What operating system and processor architecture are you using (go env)?
    linux amd64
  3. 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.
  4. What did you expect to see?
    A method akin to JS encodeURIcomponent which would encode the component the way I need.
  5. 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?

@alienth alienth closed this as completed Jun 29, 2016
@alienth alienth reopened this Jun 29, 2016
@alienth alienth changed the title net/url: No adequate method exists for escaping a URI component containing forward-slashes net/url: No adequate method exists for escaping a URI component Jun 29, 2016
@alienth alienth changed the title net/url: No adequate method exists for escaping a URI component net/url: No adequate method exists for encoding a URI component Jun 29, 2016
@ianlancetaylor
Copy link
Contributor

We use the issue tracker both for bugs and for proposals. That is what https://golang.org/wiki/Questions says, so I'm not clear on the disagreement you mention.

@ianlancetaylor ianlancetaylor added this to the Go1.8 milestone Jun 29, 2016
@alienth
Copy link
Author

alienth commented Jun 29, 2016

@ianlancetaylor Sorry, misread some instruction on this. Please disregard.

@quentinmit
Copy link
Contributor

This appears to be a dupe of #13737. Unfortunately, a suitable function does not currently exist.

@golang golang locked and limited conversation to collaborators Oct 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants