qs.parse omitting empty string keys
See original GitHub issueHi, it will be nice to have this part configurable:
https://github.com/ljharb/qs/blob/542a5c7ff88d7229efa2e22c7c8a7d69375f5e72/lib/parse.js#L150-L152
current output:
qs.parse("=1&=2") === {}
qs.parse(" =1& =2") === { " ": ["1","2"] }
expected output :
qs.parse("=1&=2", { allowEmptyKeys: true }) === { "": ["1","2"] }
If you are ok - I can open a PR
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Remove keys with empty or null values in qs.stringify when ...
You can make a function using Object.fromEntries and Object.entries to filter out non-null and non-empty values:
Read more >Option to preserve empty arrays and objects at "qs.stringify()"
I'm trying to persist query string which contains complex JSON structure on page refresh. This is why inconsistency matters for my case.
Read more >294fa139fae33e2a5ad12badf4d...
qs. A querystring parsing and stringifying library with some added security. ... Empty strings and null values will omit the value, but the...
Read more >Reference - Nginx.org
More advanced parsing scenarios can be achieved with the Query String module and with the $args variable, for example: import qs from 'querystring'; ......
Read more >Issues · ljharb/qs · GitHub
qs.parse (with allowDots) provided with the same key object and strings gives varying results bug parse. #122 opened on Oct 19, 2015 by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
“USP supports it” is a good argument, although your use cases are not convincing - if the key’s not present yet, then the value isn’t either, and I’m not clear on why the key would really evaluate to an empty string.
The PR adding this would have to add it to both parse and stringify, so that there could be a round trip.
Additionally, what happens with
=1&=2
, in the arrayFormat repeat vs brackets? What about[]=1&[]=2
?@ljharb opened #433 👍