-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
'querystring.parse' works a inconsistent way with URLSearchParams(chrome) and python's urlparse.parse_qs #10454
Comments
The If you're actually parsing a url, have you tried using the experimental WHATWG URL object in recent versions of node ( It doesn't seem that the WHATWG implementation is exporting its |
Currently even /cc @nodejs/url |
Like @TimothyGu said, we need to update the Lines 614 to 618 in 6b6123c
I opened a PR for it on #10967 😃 |
+ update state machine in parse + repeated sep should be adjusted + `&=&=` should be `{ '': [ '', '' ] }` + add test cases for querystring and URLSearchParams Fixes: nodejs#10454
+ update state machine in parse + repeated sep should be adjusted + `&=&=` should be `{ '': [ '', '' ] }` + add test cases for querystring and URLSearchParams Fixes: nodejs#10454
Unfortunately, some cases still do not work as expected even after @watilde's fix: > querystring.parse('a&&b')
{ a: '', '': '', b: '' }
> querystring.parse('a=a&&b=b')
{ a: 'a', '': '', b: 'b' } |
- posIdx should save the current position instead of the last position. Fixed cases: - `a&&b` => `{ 'a': '', 'b': '' }` - `a=a&&b=b` => `{ 'a': 'a', 'b': 'b' }` Fixes nodejs#10454
This commit fixes handling of empty pairs that occur before the end of the query string so that they are also ignored. Additionally, some optimizations have been made, including: * Avoid unnecessary code execution where possible * Use a lookup table when checking for hex characters * Avoid forced decoding when '+' characters are encountered and we are using the default decoder Fixes: nodejs#10454
* update state machine in parse * repeated sep should be adjusted * `&=&=` should be `{ '': [ '', '' ] }` * add test cases for querystring and URLSearchParams Fixes: nodejs#10454 PR-URL: nodejs#10967 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
when parse a paramsString like "&&q=test&topic=api", where '&&' appear together, Node will get the result like this:
But in other environment, such as Chrome console, we will get the result below:
The same as python.
The text was updated successfully, but these errors were encountered: