-
-
Notifications
You must be signed in to change notification settings - Fork 731
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
qs.parse generates invalid and unexpected boolean values in some special cases #425
Comments
What structure would you expect from this nonsensical query string? (meaning, what do you think the proper behavior should be) |
Note that we do have existing tests that rely on this behavior Lines 604 to 630 in 24c19cc
Perhaps it's just that the documentation needs to be updated? |
Well if qs include test to check if its bugs remains what can i do ? :D The QS documentation say it can only output "string" values in the readme, Example : Which seems to be the normal behaviors. So for what i understand this is breaking at least 3 things :
So for me it should return an array with the object first and the value of the 2nd parameter in the second index. |
The existence of the tests suggests it's not a bug, but is intentional behavior. For any software, the docs aren't necessarily authoritative - docs can have bugs just like anything else.
That syntax would be To be honest, I'd expect either of these query strings to throw an exception, since they're nonsensical, but obviously that would be a breaking change. "Specified to only output strings" is a bug in the documentation. That's not how qs has ever behaved. I'll look further into this, but I'm still not sure how it'd be possible to do something sensible. |
Well, i was thinking that as qs is a converter, it should work like a mathematical iso function and logically apply the same rules to the same cases :
Give So this is saying "successive same keys generate array" the same way as "foo[]=123&foo[]=stuffs" That's said, i understand you're point of view... moreover qs is an old lib with historical choices from the js stone age But it is also a central library for all modern JS / node applications... this type of behavior is a risk for all developers and projects because hardly anyone can really consider them despite the time and money involved. Maybe one day or another qs should make a new major version without this kind of historical bugs, and people who really want theses behaviors will stay on the previous major.. |
It's not about "JS stone age", it's the way query strings work on the web and on many popular webservers across many languages. The web can't have a major version, so these constraints can never be shed. When you have "no brackets", or "only brackets on repeated things" - which is a coherent query string - This issue is about what |
Hi !
We found an unexpected qs.parse output with a boolean as the value and a value as the key using a specific query string construct.
The bug seems to occur when qs.parse needs to transcribe a property that has already been created with an object as the value.
Here an simple example of this behavior :
qs.parse("foo[bar]=stuffs&foo=123")
will output :
{ foo:{ '123': true, bar: 'stuffs' } }
Hgd :)
The text was updated successfully, but these errors were encountered: