-
-
Notifications
You must be signed in to change notification settings - Fork 728
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: follow allowPrototypes during merge #201
Conversation
b22352e
to
db3155c
Compare
I'm not sure what's the purpose of this commit 50ea161 , but I think it didn't fix prototype overwrite. |
The purpose of the commit is in the commit message, and the added tests shows exactly what it inarguably did fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good, just a few comments.
|
||
st.deepEqual( | ||
qs.parse('a[b]=c&a=toString', { allowPrototypes: true }), | ||
{ a: { b: 'c', toString: true } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case, shouldn't a[b]
be entirely overwritten by the string "toString"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this test case t.deepEqual(qs.parse('a[b]=c&a=d'), { a: { b: 'c', d: true } }, 'can add keys to objects');
, is this a feature by design?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point :-) let's keep this as-is for now.
dist/qs.js
Outdated
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file shouldn't be updated in PRs; please revert it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
after 50ea161 , qs.parse('[=a'); // { a: true }
qs.parse(']=a'); // { ']': 'a'} Is this the expected result? |
db3155c
to
114d7fb
Compare
if we revert the change of
|
@dead-horse the second line in your example is the expected result, which is what it did, actually, fix. The first line is an oversight, obviously, hence #200. |
That test is valid; I would expect |
I want to know the diff in 50ea161?diff=split#diff-e6c9a6bca996bc454cc244d17bfeda5cL125 - st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: false }), { a: { '0': 'b', c: true, t: 'u' } });
+ st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: false }), { a: { 0: 'b', t: 'u' } }); Is it a expected change? it seems a break change that change string to number. |
@popomore in JS, all keys are strings (or Symbols), so |
114d7fb
to
ec9e736
Compare
closes #200