You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To me it suggests that with this option disabled I should never get an array. Other interpretation could be that this applies only to a[] and a[0] notations, since the "Parsing arrays" section mentions only those two notations and parsing repeating keys as arrays is mentioned only in the duplicates section (counter point: the test for a=b&a=c was literally called a simple array test in one of the first commits to this repository - 622da20).
On the current main (6bdfaf5) (should be same in 16.4.1) and 16.4.0 I see the following behaviour:
This is not what I would expect based on the documentation (readme), but I think I may know the historical reason for this behaviour. arrayLimit was intended (until 16.4.1) to restrict only arrays with explicit indexes (see 4667c41, 8c5cda3, #294 and a longer analysis in #537 (comment)) and I believe parseArrays: false was meant to replace arrayLimit: -1 (#60, cc735a5) and affect the notation with indices, not repetitions (8e299ca).
This is related also to #260 and 2b94ea7, which extended parseArrays from indexed-only to also apply to [] notation, without index.
I think this is a documentation "bug" that requires clarification or maybe a combination of documentation and code problems (especially with changes to 6.14.1), but this requires answering some questions:
Should parseArrays: false be equivalent to arrayLimit: -1?
If not, then how does it affect duplicates: 'combine'? (it doesn't, but should this be considered a bug?)
In any case, the documentation is very vague and needs clarification.
With
duplicatesset to'combine'(default)parseArrays: falsecan parse some query strings as arrays. The readme says:qs/README.md
Lines 313 to 318 in 6bdfaf5
To me it suggests that with this option disabled I should never get an array. Other interpretation could be that this applies only to
a[]anda[0]notations, since the "Parsing arrays" section mentions only those two notations and parsing repeating keys as arrays is mentioned only in theduplicatessection (counter point: the test fora=b&a=cwas literally called a simple array test in one of the first commits to this repository - 622da20).On the current main (6bdfaf5) (should be same in 16.4.1) and 16.4.0 I see the following behaviour:
arrayLimitparseArraysa=b&a=cfalse{ a: [ 'b', 'c' ] }{ a: [ 'b', 'c' ] }a[]=b&a[]=cfalse{ a: { '0': [ 'b', 'c' ] } }{ a: { '0': [ 'b', 'c' ] } }a=b&a=ctrue{ a: [ 'b', 'c' ] }{ a: [ 'b', 'c' ] }a[]=b&a[]=ctrue{ a: [ 'b', 'c' ] }{ a: [ 'b', 'c' ] }a=b&a=cfalse{ a: { '0': 'b', '1': 'c' } }{ a: [ 'b', 'c' ] }a[]=b&a[]=cfalse{ a: { '0': { '0': 'b', '1': 'c' } } }{ a: { '0': [ 'b', 'c' ] } }a=b&a=ctrue{ a: { '0': 'b', '1': 'c' } }{ a: [ 'b', 'c' ] }a[]=b&a[]=ctrue{ a: { '0': 'b', '1': 'c' } }{ a: [ 'b', 'c' ] }This is not what I would expect based on the documentation (readme), but I think I may know the historical reason for this behaviour.
arrayLimitwas intended (until 16.4.1) to restrict only arrays with explicit indexes (see 4667c41, 8c5cda3, #294 and a longer analysis in #537 (comment)) and I believeparseArrays: falsewas meant to replacearrayLimit: -1(#60, cc735a5) and affect the notation with indices, not repetitions (8e299ca).This is related also to #260 and 2b94ea7, which extended
parseArraysfrom indexed-only to also apply to[]notation, without index.I think this is a documentation "bug" that requires clarification or maybe a combination of documentation and code problems (especially with changes to 6.14.1), but this requires answering some questions:
parseArrays: falsebe equivalent toarrayLimit: -1?duplicates: 'combine'? (it doesn't, but should this be considered a bug?)arrayLimitapply to arrays without explicit index (Query string array parsing behavior changed in version 6.14.1 #537)?a[]=b&a[]=cbehave differently froma=b&a=cand create a sub-object with key'0'that contains an array/object?qs.parsewhen parsing a string with empty indexes[]in a key. #260, but I did not test older versions).