Skip to content

Commit

Permalink
Fixed handling of parameters with names that are keys in Object.proto…
Browse files Browse the repository at this point in the history
…type.
  • Loading branch information
MaxNanasy committed May 25, 2012
1 parent 6014c13 commit ec28f81
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion querystring.js
Expand Up @@ -145,7 +145,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq) {
var k = QueryString.unescape(x[0], true); var k = QueryString.unescape(x[0], true);
var v = QueryString.unescape(x.slice(1).join(eq), true); var v = QueryString.unescape(x.slice(1).join(eq), true);


if (!(k in obj)) { if (!(obj.hasOwnProperty(k))) {
obj[k] = v; obj[k] = v;
} else if (!Array.isArray(obj[k])) { } else if (!Array.isArray(obj[k])) {
obj[k] = [obj[k], v]; obj[k] = [obj[k], v];
Expand Down
3 changes: 2 additions & 1 deletion test-querystring.js
Expand Up @@ -26,7 +26,8 @@ var qsTestCases = [
'undef': ''}], 'undef': ''}],
[' foo = bar ', '%20foo%20=%20bar%20', {' foo ': ' bar '}], [' foo = bar ', '%20foo%20=%20bar%20', {' foo ': ' bar '}],
['foo=%zx', 'foo=%25zx', {'foo': '%zx'}], ['foo=%zx', 'foo=%25zx', {'foo': '%zx'}],
['foo=%EF%BF%BD', 'foo=%EF%BF%BD', {'foo': '\ufffd' }] ['foo=%EF%BF%BD', 'foo=%EF%BF%BD', {'foo': '\ufffd' }],
['toString=bar', 'toString=bar', {'toString': 'bar'}]
]; ];


// [ wonkyQS, canonicalQS, obj ] // [ wonkyQS, canonicalQS, obj ]
Expand Down

0 comments on commit ec28f81

Please sign in to comment.