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 +7 -0
- package/Makefile +4 -4
- package/README.md +2 -0
- package/index.js +1 -1
- package/lib/parse.js +1 -0
- package/lib/utils.js +2 -2
- package/package.json +3 -2
- package/test/parse.js +23 -16
- package/test/stringify.js +3 -1
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
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./lib');
|
|
1
|
+
module.exports = require('./lib/');
|
package/lib/parse.js
CHANGED
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,
|
|
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 (
|
|
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.
|
|
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
|
-
"
|
|
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 =
|
|
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
|
-
|
|
313
|
-
|
|
316
|
+
'user[name]': {'pop[bob]': 3},
|
|
317
|
+
'user[email]': null
|
|
314
318
|
};
|
|
315
319
|
|
|
316
320
|
var expected = {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
333
|
-
|
|
336
|
+
'user[name]': {'pop[bob]': { 'test': 3 }},
|
|
337
|
+
'user[email]': null
|
|
334
338
|
};
|
|
335
339
|
|
|
336
340
|
var expected = {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
-
|
|
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(
|
|
379
|
+
}).to.not.throw();
|
|
375
380
|
|
|
376
|
-
expect(parsed).to.
|
|
377
|
-
expect(parsed.foo).to.
|
|
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
|
-
|
|
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 =
|
|
17
|
+
var expect = Code.expect;
|
|
16
18
|
var describe = lab.experiment;
|
|
17
19
|
var it = lab.test;
|
|
18
20
|
|