-
-
Notifications
You must be signed in to change notification settings - Fork 755
Closed
Description
I think there is a bug in parseArrays: false option:
normal case with index
qs.parse('a[0]=b', { arrayLimit: 0 }) === { a: [ 'b' ] } // true <-- expected
qs.parse('a[0]=b', { parseArrays: false }) === { a: { '0': 'b' } } // true <-- expectedbuggy case with empty index
qs.parse('a[]=b', { arrayLimit: 0 }) === '{ a: [ 'b' ] }' // true <-- expected
qs.parse('a[]=b', { parseArrays: false }) === '{ a: [ 'b' ] }' // true <-- unexpectedInstead, I will expect if I set parseArrays: false, I will receive no Array:
qs.parse('a[]=b', { parseArrays: false }) === '{ 'a': { '0': 'b' } }' // trueThat is because the array parsing is only preserving the order, not by their true indexes in the query, according to the doc:
qs will compact a sparse array to only the existing values preserving their order
Also it is consistent with when other option being set (i.e. treat [] as [0], see below.)