Say we have an Object we are stringifying to become a query param of the following shape (notice the comma in the value)
const singleQueryObject = { not_important: [ "I, am, one, single, value"]};
// OR (the value can also just be a plain string, not an array like the above)
const singleQueryObject = { not_important: "I, am, one, single, value" };
const stringifyResult = queryString.stringify(singleQueryObject, { arrayFormat: 'comma' });
//=> 'not_important=I%2C%20am%2C%20one%2C%20single%2C%20value'
const parsedResult = queryString.parse(stringifyResult, { arrayFormat: 'comma' });
//=> { not_important: [ 'I', ' am', ' one', ' single', ' value' ] }
(Expected)
{ not_important: [ 'I, am, one, single, value' ] };
This bug only occurs when there is a single value. So say if we run the same step as above with this object instead:
const singleQueryObject = { not_important: [ 'I, am, one, single, value', 'It works!'] };
const stringifyResult = queryString.stringify(singleQueryObject, { arrayFormat: 'comma' });
const parsedResult = queryString.parse(stringifyResult, { arrayFormat: 'comma' });
//=> { not_important: [ 'I, am, one, single, value', 'It works!' ] }
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too