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

qs.parse (with allowDots) provided with the same key object and strings gives varying results #122

Open
MadManMathew opened this issue Oct 19, 2015 · 0 comments

Comments

@MadManMathew
Copy link

When using qs to parse our url for advanced queries I came across an issue where we get varying/expected or desired results when we provide the same parent key one as string and the other intended to be an object. The example will clear things up.

qs.parse('address=123+main+st&address.city=vancouver' ,{allowDots:true});
  //  returns  {address: [ 123+main+stf', { city: 'vancouver' } ] }

which is as expected, however if we reverse the order

qs.parse('address.city=vancouver&address=123+main+st' ,{allowDots:true});
  //  returns  {address: { city: 'vancouver',  '123+main+st':true }  }

order shouldn't matter. Once again

qs.parse('address.city=vancouver&address=123+main+st&address=321+baltic+ave' ,{allowDots:true});
  //  returns  {address: { city: 'vancouver',  '0': '123+main+st', '1':'321+baltic+ave}  }

Solution

keep the results consistent and use the object array notation in each of the cases

@nlf nlf added the bug label Oct 20, 2015
@ljharb ljharb changed the title qs.parse (with alowDots ) provided with the same key object and strings gives varying results qs.parse (with allowDots) provided with the same key object and strings gives varying results Feb 9, 2016
ljharb pushed a commit to MadManMathew/qs that referenced this issue May 30, 2017
ljharb pushed a commit to MadManMathew/qs that referenced this issue May 30, 2017
@ljharb ljharb added the parse label Jun 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants