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

+ should be decoded to +, not to a space #3

Closed
lebed2045 opened this issue Aug 21, 2019 · 6 comments · May be fixed by aakram786/appsyncmasterclass-backend#5
Closed

+ should be decoded to +, not to a space #3

lebed2045 opened this issue Aug 21, 2019 · 6 comments · May be fixed by aakram786/appsyncmasterclass-backend#5

Comments

@lebed2045
Copy link

Found a bug in my our project because of this lib https://www.npmjs.com/package/query-string depends on your library which basically incompatible with industry standard https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

@Anusien
Copy link

Anusien commented Sep 20, 2019

See this comment. I don't think decode-uri-component is responsible for this.

@adguy360
Copy link

adguy360 commented Oct 24, 2022

See this comment. I don't think decode-uri-component is responsible for this.

Of course it's responsible https://github.com/SamVerschueren/decode-uri-component/blob/main/index.js#L86, and it also breaks query-string.

Not sure how this pkg was ever a "better decodeURIComponent" (as it claims to be) but you should definitely avoid using it, and better avoid query-string as well if you can - native solutions are better and certainly better maintained.

If you have query-string as a nested dependency and need some simple sketchy fix, you can encodeURIComponent your value before passing it to query-string's stringify. This will "hide" the + sign from this pkg's nasty parsing logic.

@SamVerschueren
Copy link
Owner

Not sure how this pkg was ever a "better decodeURIComponent" (as it claims to be) but you should definitely avoid using it

Try decoding %7B%ab%%7C%de%%7D with the native decodeURIComponent and then come back with some useful feedback.

When I created this package (which was specifically made for query-string if I'm not mistaken), it seemed like the right thing to do. Which might be the case for query string values, but not for other parts of the URI. So I think it makes sense to remove it in this package.

cc @sindresorhus do you think that makes sense?

@sindresorhus
Copy link
Collaborator

sindresorhus commented Dec 12, 2022

Yes, the special + handling is a query string only thing, not for all URL components.

https://stackoverflow.com/a/6855723/64949

@SamVerschueren
Copy link
Owner

Ok, I'll remove the + handling and publish a new breaking change.

@SamVerschueren
Copy link
Owner

Released as 0.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants