-
-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: Decode back-separator value before splitting it with separator #392
FIX: Decode back-separator value before splitting it with separator #392
Conversation
The original implementation was splitting the received value before it then decoded the value. Because the value was URL encoded, the split function could not find the seperator to successfully split. Adjusted the order of operations which fixes #388
a0d90c5
to
245ffe0
Compare
245ffe0
to
8c0335d
Compare
Thanks for reviewing @sindresorhus 🙌 I've adjusted the test to be more readable with regards to the encoded strings. There's some existing tests that are using encoded values without showing the un-encoded version. Do you want me to adjust these to conform to your comment? |
Yeah, that would be great. |
Sweet @sindresorhus, I've updated the tests and they should be more readable. Let me know if there's any issues. |
Thanks :) |
Not sure if it was an expected change but with 9.1.1 if we run the code below: import queryString from 'query-string';
const original = { key: [','] };
console.log({ original });
const stringified = queryString.stringify(original, { arrayFormat: 'bracket-separator' });
console.log({ stringified });
const parsed = queryString.parse(stringified, { arrayFormat: 'bracket-separator' });
console.log({ parsed }); We get something different from what we had in 9.1.0. At some point the // in 9.1.1
{ original: { key: [ ',' ] } }
{ stringified: 'key[]=%2C' }
{ parsed: [Object: null prototype] { key: [ '', '' ] } }
// in 9.1.0
{ original: { key: [ ',' ] } }
{ stringified: 'key[]=%2C' }
{ parsed: [Object: null prototype] { key: [ ',' ] } } I suspect that it might not be totally expected but maybe I'm wrong. |
The original implementation was splitting the received value before it then decoded the value. Because the value was URL encoded, the split function could not find the separator to successfully split. Adjusted the order of operations which fixes #388