Browse Source

querystring.parse: handle undefined value properly

v0.7.4-release
cloudhead 15 years ago
committed by Ryan Dahl
parent
commit
fe3e419687
  1. 1
      lib/querystring.js
  2. 3
      test/simple/test-querystring.js

1
lib/querystring.js

@ -77,6 +77,7 @@ var chunks = /(?:(?:^|\.)([^\[\(\.]+)(?=\[|\.|$|\()|\[([^"'][^\]]*?)\]|\["([^\]"
// Parse a key=val string.
QueryString.parse = QueryString.decode = function (qs, sep, eq) {
var obj = {};
if (qs === undefined) { return {} }
String(qs).split(sep || "&").map(function (keyValue) {
var res = obj,
next,

3
test/simple/test-querystring.js

@ -165,3 +165,6 @@ var f = qs.stringify({
}, ";", ":")
}, ";", ":");
assert.equal(f, "a:b;q:x%3Ay%3By%3Az");
assert.deepEqual({}, qs.parse());

Loading…
Cancel
Save