qs 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/utils.js CHANGED
@@ -10,7 +10,11 @@ exports.arrayToObject = function (source) {
10
10
 
11
11
  var obj = {};
12
12
  for (var i = 0, il = source.length; i < il; ++i) {
13
- obj[i] = source[i];
13
+ if (source[i] !== undefined &&
14
+ source[i] !== null) {
15
+
16
+ obj[i] = source[i];
17
+ }
14
18
  }
15
19
 
16
20
  return obj;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qs",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A querystring parser that supports nesting and arrays, with a depth limit",
5
5
  "homepage": "https://github.com/hapijs/qs",
6
6
  "main": "index.js",
package/test/parse.js CHANGED
@@ -141,6 +141,12 @@ describe('#parse', function () {
141
141
  done();
142
142
  });
143
143
 
144
+ it('correctly prunes undefined values when converting an array to an object', function (done) {
145
+
146
+ expect(Qs.parse('a[2]=b&a[99999999]=c')).to.deep.equal({ a: { '2': 'b', '99999999': 'c' } });
147
+ done();
148
+ });
149
+
144
150
  it('supports malformed uri characters', function (done) {
145
151
 
146
152
  expect(Qs.parse('{%:%}')).to.deep.equal({ '{%:%}': '' });