-
-
Notifications
You must be signed in to change notification settings - Fork 456
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
Regression introduced in 9.1.1: parse cannot read back stringify when using bracket-seperator mode #398
Comments
// @scottenock |
Thanks @sindresorhus - taking a look 💪 |
Hi @sindresorhus + @dubzzz - I managed to take a look at this and have determined that @dubzzz , in your example you are using
Note that your example will still work and be Idempotent if you specify an
Also note that in both
If you're happy with my findings @sindresorhus I think we can close this out 💪 |
Well in such a case you have an issue for an input being: const original = { key: ['|'] }; More precisely how to handle something like: const original = { key: [[...Array(256)].map((_, i) => String.fromCodePoint(i)).join('')] }; |
Happy new year everyone! 🥳 @dubzzz I'm not sure what you mean with that example? |
Let suppose I don't control the input of my user. My user could pass any string called const inputStringified = queryString.stringify(input, {
arrayFormat: "bracket-separator",
arrayFormatSeparator: "|",
});
const output = queryString.parse(inputStringified, {
arrayFormat: "bracket-separator",
arrayFormatSeparator: "|",
}); Well, it's not the case following your change. If you take Why is it an issue? Because it means that as a end user of the library we have to tweak the input to make it reversible. Before the change introduced in 9.1.1 it used to be reversible no matter the input. Said differently: Let say I want to use the arrayFormat bracket-separator with: const input = {
key: [
[...Array(1_048_576)]
.map((_, i) => String.fromCodePoint(i))
.filter((_, i) => i < 0xd800 || i > 0xdfff)
.join(""),
],
}; How can I do to make sure parse can reverse stringify? At the moment neither: |
Thanks for the details @dubzzz , I think we need @sindresorhus's input on this. As I have mentioned the behaviour outlined in the suspected regression for the So, the change in Here are the outputs we get for each version when using // 9.1.1
{ original: { key: [ ',' ] } }
{ stringified: 'key=%2C' }
{ parsed: [Object: null prototype] { key: [ '', '' ] } }
// 9.1.0
{ original: { key: [ ',' ] } }
{ stringified: 'key=%2C' }
{ parsed: [Object: null prototype] { key: [ '', '' ] } }
//9.0.0
{ original: { key: [ ',' ] } }
{ stringified: 'key=%2C' }
{ parsed: [Object: null prototype] { key: [ '', '' ] } }
//8.2.0
{ original: { key: [ ',' ] } }
{ stringified: 'key=%2C' }
{ parsed: [Object: null prototype] { key: [ '', '' ] } }
//7.1.3
{ original: { key: [ ',' ] } }
{ stringified: 'key=%2C' }
{ parsed: [Object: null prototype] { key: [ '', '' ] } } As the above shows, this behaviour goes back to version So my take is that this isn't a regression and is fixing the inconsistent behaviour of the Keen to get @sindresorhus thoughts on this, as if this is truly regression then this bug has existed since version |
Not sure if it was an expected impact of #392, but it seems it introduced a regression in 9.1.1.
The following piece of code does not behave the same in 9.1.0 and 9.1.1. In the later the
parse
function cannot read back itself.Here are the output we get for each version:
The text was updated successfully, but these errors were encountered: