ljharb/qs
Vedi su GitHubStringify with `comma` format should add square brackets to parameter name to identity array with single value
Open
#315 aperta il 4 giu 2019
enhancementhelp wantedstringify
Metriche repository
- Star
- (8015 star)
- Metriche merge PR
- (Merge medio 6g 22h) (2 PR mergiate in 30 g)
Descrizione
Hi. With new comma array format, stringify of array with single value will produce following result:
const options = {
arrayFormat: 'comma'
};
qs.stringify({foo: [1]}, options); // foo=1
qs.stringify({foo: [1, 2]}, options); // foo=1,2
So, on parse stage, parsing will produce single value.
qs.parse('foo=1); // {foo: 1}
qs.parse('foo=1,2'); // {foo: [1, 2]}
Maybe add square brackets to parameter name, when comma array format is used?
qs.stringify({foo: [1]}, options); // foo[]=1
qs.stringify({foo: [1, 2]}, options); // foo[]=1,2
qs.parse('foo[]=1); // {foo: [1]}
qs.parse('foo[]=1,2'); // {foo: [1, 2]}
Currently, parsing of the following query string foo[]=1,2 working as expected