qs 2.3.2 → 2.3.3

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/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ ## [**2.3.3**](https://github.com/hapijs/qs/issues?milestone=18&state=open)
3
+ - [**#59**](https://github.com/hapijs/qs/issues/59) make sure array indexes are >= 0, closes #57
4
+ - [**#58**](https://github.com/hapijs/qs/issues/58) make qs usable for browser loader
5
+
6
+ ## [**2.3.2**](https://github.com/hapijs/qs/issues?milestone=17&state=closed)
7
+ - [**#55**](https://github.com/hapijs/qs/issues/55) allow merging a string into an object
8
+
2
9
  ## [**2.3.1**](https://github.com/hapijs/qs/issues?milestone=16&state=closed)
3
10
  - [**#52**](https://github.com/hapijs/qs/issues/52) Return "undefined" and "false" instead of throwing "TypeError".
4
11
 
package/Makefile CHANGED
@@ -1,8 +1,8 @@
1
1
  test:
2
- @node node_modules/lab/bin/lab
2
+ @node node_modules/lab/bin/lab -a code -L
3
3
  test-cov:
4
- @node node_modules/lab/bin/lab -t 100
4
+ @node node_modules/lab/bin/lab -a code -t 100 -L
5
5
  test-cov-html:
6
- @node node_modules/lab/bin/lab -r html -o coverage.html
6
+ @node node_modules/lab/bin/lab -a code -L -r html -o coverage.html
7
7
 
8
- .PHONY: test test-cov test-cov-html
8
+ .PHONY: test test-cov test-cov-html
package/README.md CHANGED
@@ -153,6 +153,8 @@ Qs.parse('a[1]=b', { arrayLimit: 0 });
153
153
  // { a: { '1': 'b' } }
154
154
  ```
155
155
 
156
+ To disable array parsing entirely, set `arrayLimit` to `-1`.
157
+
156
158
  If you mix notations, **qs** will merge the two items into an object:
157
159
 
158
160
  ```javascript
package/index.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./lib');
1
+ module.exports = require('./lib/');
package/lib/parse.js CHANGED
@@ -62,6 +62,7 @@ internals.parseObject = function (chain, val, options) {
62
62
  if (!isNaN(index) &&
63
63
  root !== cleanRoot &&
64
64
  indexString === cleanRoot &&
65
+ index >= 0 &&
65
66
  index <= options.arrayLimit) {
66
67
 
67
68
  obj = [];
package/lib/utils.js CHANGED
@@ -94,7 +94,7 @@ exports.compact = function (obj, refs) {
94
94
  if (Array.isArray(obj)) {
95
95
  var compacted = [];
96
96
 
97
- for (var i = 0, l = obj.length; i < l; ++i) {
97
+ for (var i = 0, il = obj.length; i < il; ++i) {
98
98
  if (typeof obj[i] !== 'undefined') {
99
99
  compacted.push(obj[i]);
100
100
  }
@@ -104,7 +104,7 @@ exports.compact = function (obj, refs) {
104
104
  }
105
105
 
106
106
  var keys = Object.keys(obj);
107
- for (var i = 0, il = keys.length; i < il; ++i) {
107
+ for (i = 0, il = keys.length; i < il; ++i) {
108
108
  var key = keys[i];
109
109
  obj[key] = exports.compact(obj[key], refs);
110
110
  }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "qs",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
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",
7
7
  "dependencies": {},
8
8
  "devDependencies": {
9
- "lab": "4.x.x"
9
+ "code": "1.x.x",
10
+ "lab": "5.x.x"
10
11
  },
11
12
  "scripts": {
12
13
  "test": "make test-cov"
package/test/parse.js CHANGED
@@ -1,5 +1,7 @@
1
+ /* eslint no-extend-native:0 */
1
2
  // Load modules
2
3
 
4
+ var Code = require('code');
3
5
  var Lab = require('lab');
4
6
  var Qs = require('../');
5
7
 
@@ -12,7 +14,7 @@ var internals = {};
12
14
  // Test shortcuts
13
15
 
14
16
  var lab = exports.lab = Lab.script();
15
- var expect = Lab.expect;
17
+ var expect = Code.expect;
16
18
  var describe = lab.experiment;
17
19
  var it = lab.test;
18
20
 
@@ -302,6 +304,8 @@ describe('parse()', function () {
302
304
 
303
305
  it('allows overriding array limit', function (done) {
304
306
 
307
+ expect(Qs.parse('a[0]=b', { arrayLimit: -1 })).to.deep.equal({ a: { '0': 'b' } });
308
+ expect(Qs.parse('a[-1]=b', { arrayLimit: -1 })).to.deep.equal({ a: { '-1': 'b' } });
305
309
  expect(Qs.parse('a[0]=b&a[1]=c', { arrayLimit: 0 })).to.deep.equal({ a: { '0': 'b', '1': 'c' } });
306
310
  done();
307
311
  });
@@ -309,14 +313,14 @@ describe('parse()', function () {
309
313
  it('parses an object', function (done) {
310
314
 
311
315
  var input = {
312
- "user[name]": {"pop[bob]": 3},
313
- "user[email]": null
316
+ 'user[name]': {'pop[bob]': 3},
317
+ 'user[email]': null
314
318
  };
315
319
 
316
320
  var expected = {
317
- "user": {
318
- "name": {"pop[bob]": 3},
319
- "email": null
321
+ 'user': {
322
+ 'name': {'pop[bob]': 3},
323
+ 'email': null
320
324
  }
321
325
  };
322
326
 
@@ -329,14 +333,14 @@ describe('parse()', function () {
329
333
  it('parses an object and not child values', function (done) {
330
334
 
331
335
  var input = {
332
- "user[name]": {"pop[bob]": { "test": 3 }},
333
- "user[email]": null
336
+ 'user[name]': {'pop[bob]': { 'test': 3 }},
337
+ 'user[email]': null
334
338
  };
335
339
 
336
340
  var expected = {
337
- "user": {
338
- "name": {"pop[bob]": { "test": 3 }},
339
- "email": null
341
+ 'user': {
342
+ 'name': {'pop[bob]': { 'test': 3 }},
343
+ 'email': null
340
344
  }
341
345
  };
342
346
 
@@ -350,8 +354,9 @@ describe('parse()', function () {
350
354
 
351
355
  var tempBuffer = global.Buffer;
352
356
  delete global.Buffer;
353
- expect(Qs.parse('a=b&c=d')).to.deep.equal({ a: 'b', c: 'd' });
357
+ var result = Qs.parse('a=b&c=d');
354
358
  global.Buffer = tempBuffer;
359
+ expect(result).to.deep.equal({ a: 'b', c: 'd' });
355
360
  done();
356
361
  });
357
362
 
@@ -371,10 +376,10 @@ describe('parse()', function () {
371
376
  expect(function () {
372
377
 
373
378
  parsed = Qs.parse({ 'foo[bar]': 'baz', 'foo[baz]': a });
374
- }).to.not.throw(Error);
379
+ }).to.not.throw();
375
380
 
376
- expect(parsed).to.have.key('foo');
377
- expect(parsed.foo).to.have.keys('bar', 'baz');
381
+ expect(parsed).to.contain('foo');
382
+ expect(parsed.foo).to.contain('bar', 'baz');
378
383
  expect(parsed.foo.bar).to.equal('baz');
379
384
  expect(parsed.foo.baz).to.deep.equal(a);
380
385
  done();
@@ -386,7 +391,9 @@ describe('parse()', function () {
386
391
  a.b = 'c';
387
392
 
388
393
  expect(Qs.parse(a)).to.deep.equal({ b: 'c' });
389
- expect(Qs.parse({ a: a })).to.deep.equal({ a: { b: 'c' } });
394
+ var result = Qs.parse({ a: a });
395
+ expect(result).to.contain('a');
396
+ expect(result.a).to.deep.equal(a);
390
397
  done();
391
398
  });
392
399
 
package/test/stringify.js CHANGED
@@ -1,5 +1,7 @@
1
+ /* eslint no-extend-native:0 */
1
2
  // Load modules
2
3
 
4
+ var Code = require('code');
3
5
  var Lab = require('lab');
4
6
  var Qs = require('../');
5
7
 
@@ -12,7 +14,7 @@ var internals = {};
12
14
  // Test shortcuts
13
15
 
14
16
  var lab = exports.lab = Lab.script();
15
- var expect = Lab.expect;
17
+ var expect = Code.expect;
16
18
  var describe = lab.experiment;
17
19
  var it = lab.test;
18
20