diff --git a/lib/querystring.js b/lib/querystring.js index ba2b1cc9dc..69ea008548 100644 --- a/lib/querystring.js +++ b/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, diff --git a/test/simple/test-querystring.js b/test/simple/test-querystring.js index e1598465ff..0470b467f7 100644 --- a/test/simple/test-querystring.js +++ b/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());