ljharb / qs

A querystring parser with nesting support
BSD 3-Clause "New" or "Revised" License
8.5k stars 729 forks source link

The arrayFormat parameter ignored with a single-element array #444

Closed T-PWK closed 2 years ago

T-PWK commented 2 years ago

The arrayFormat parameter seems to be ignored when using a single-element array. Example:

qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'comma' })

will return a=b,c (a=b%2Cc), however, when there is a single array element like in the following example:

qs.stringify({ a: ['b'] }, { arrayFormat: 'comma' })

the library returns a[]=b (a%5B%5D=b)

This issue started appearing in the latest version 6.10.5. Version 6.10.3 works as expected.

ljharb commented 2 years ago

It’s not a bug; it’s intentional. However, it will be put behind an option; duplicate of #442.