Comparing version 0.4.1 to 0.4.2
0.4.2 / 2012-02-08 | ||
================== | ||
* Fixed: ensure objects are created when appropriate not arrays [aheckmann] | ||
0.4.1 / 2012-01-26 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -12,3 +12,3 @@ | ||
exports.version = '0.4.1'; | ||
exports.version = '0.4.2'; | ||
@@ -25,3 +25,3 @@ /** | ||
var notint = /^[^0-9]+$/; | ||
var isint = /^[0-9]+$/; | ||
@@ -63,7 +63,7 @@ function promote(parent, key) { | ||
part = part.substr(0, part.length - 1); | ||
if(notint.test(part) && Array.isArray(obj)) obj = promote(parent, key); | ||
if (!isint.test(part) && Array.isArray(obj)) obj = promote(parent, key); | ||
parse(parts, obj, part, val); | ||
// key | ||
} else { | ||
if(notint.test(part) && Array.isArray(obj)) obj = promote(parent, key); | ||
if (!isint.test(part) && Array.isArray(obj)) obj = promote(parent, key); | ||
parse(parts, obj, part, val); | ||
@@ -86,3 +86,3 @@ } | ||
} else { | ||
if (notint.test(key) && Array.isArray(parent.base)) { | ||
if (!isint.test(key) && Array.isArray(parent.base)) { | ||
var t = {}; | ||
@@ -89,0 +89,0 @@ for (var k in parent.base) t[k] = parent.base[k]; |
{ | ||
"name": "qs", | ||
"description": "querystring parser", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type" : "git", |
@@ -94,4 +94,8 @@ | ||
.should.eql({ user: { name: { first: ['tj', 'TJ'] }}}); | ||
var o = qs.parse('existing[fcbaebfecc][name][last]=tj') | ||
o.should.eql({ existing: { 'fcbaebfecc': { name: { last: 'tj' }}}}) | ||
Array.isArray(o.existing).should.be.false; | ||
}, | ||
'test right-hand brackets': function(){ | ||
@@ -98,0 +102,0 @@ qs.parse('pets=["tobi"]') |
19361
490