Open
Description
queryString.stringify({values: ['foo']}, {arrayFormat: 'comma'} )
=> values='foo'
when parsing back with arrayFormat 'comma', the result is {values: 'foo'}
here is a test to reproduce the bug (the test fails):
it("parses array with a single value bug", () => {
const q = queryString.stringify(
{ values: ["foo"] },
{ arrayFormat: "comma" },
);
console.log(q);
const parsed = queryString.parse(q, { arrayFormat: "comma" });
console.log(parsed);
expect(parsed).toEqual({
values: ["foo"],
});
});
The information that values is an array is lost when stringifying.
Workaround: use `arrayFormat: "bracket-separator"
This bug makes the "comma" format unusable.
Metadata
Metadata
Assignees
Labels
No labels