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
Simplify parseQueryString #8877
Simplify parseQueryString #8877
Conversation
let match; | ||
while ((match = regex.exec(queryString))) { | ||
const name = decodeURIComponent(match[1]).trim(); | ||
const value = match[2] ? decodeURIComponent(match[2]).trim() : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized that trimming the result of decode is probably a wrong thing :( Maybe we should do it in a separate PR, but x=value%20
should probably preserve a space in the value? Trimming pre-decoded strings is certainly fine...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm kinda of the opinion we shouldn't trim at all. We can definitely discuss this in a separate PR, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I'm leaning toward that as well. Not trimming is better than trimming in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM w/one question
* Simplify parseQueryString https://jsperf.com/parsing-query-string * Remove unused import
* Simplify parseQueryString https://jsperf.com/parsing-query-string * Remove unused import
* Simplify parseQueryString https://jsperf.com/parsing-query-string * Remove unused import
And it's faster.