qs 6.14.2 → 6.15.1
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 +168 -0
- package/README.md +18 -0
- package/dist/qs.js +9 -9
- package/lib/parse.js +5 -3
- package/lib/utils.js +2 -0
- package/package.json +3 -3
- package/test/parse.js +146 -4
- package/test/stringify.js +9 -0
- package/test/utils.js +38 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## **6.15.1**
|
|
2
|
+
- [Fix] `parse`: `parameterLimit: Infinity` with `throwOnLimitExceeded: true` silently drops all parameters
|
|
3
|
+
- [Deps] update `@ljharb/eslint-config`
|
|
4
|
+
- [Dev Deps] update `@ljharb/eslint-config`, `iconv-lite`
|
|
5
|
+
- [Tests] increase coverage
|
|
6
|
+
|
|
7
|
+
## **6.15.0**
|
|
8
|
+
- [New] `parse`: add `strictMerge` option to wrap object/primitive conflicts in an array (#425, #122)
|
|
9
|
+
- [Fix] `duplicates` option should not apply to bracket notation keys (#514)
|
|
10
|
+
|
|
1
11
|
## **6.14.2**
|
|
2
12
|
- [Fix] `parse`: mark overflow objects for indexed notation exceeding `arrayLimit` (#546)
|
|
3
13
|
- [Fix] `arrayLimit` means max count, not max index, in `combine`/`merge`/`parseArrayValue`
|
|
@@ -30,6 +40,17 @@
|
|
|
30
40
|
- [Dev Deps] update `es-value-fixtures`, `has-bigints`, `has-proto`, `has-symbols`
|
|
31
41
|
- [Tests] increase coverage
|
|
32
42
|
|
|
43
|
+
## **6.13.3**
|
|
44
|
+
[Fix] fix regressions from robustness refactor
|
|
45
|
+
[actions] update reusable workflows
|
|
46
|
+
|
|
47
|
+
## **6.13.2**
|
|
48
|
+
- [Robustness] avoid `.push`, use `void`
|
|
49
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
50
|
+
- [readme] document that `addQueryPrefix` does not add `?` to empty output (#418)
|
|
51
|
+
- [readme] replace runkit CI badge with shields.io check-runs badge
|
|
52
|
+
- [actions] fix rebase workflow permissions
|
|
53
|
+
|
|
33
54
|
## **6.13.1**
|
|
34
55
|
- [Fix] `stringify`: avoid a crash when a `filter` key is `null`
|
|
35
56
|
- [Fix] `utils.merge`: functions should not be stringified into keys
|
|
@@ -46,6 +67,17 @@
|
|
|
46
67
|
- [New] `parse`: add `strictDepth` option (#511)
|
|
47
68
|
- [Tests] use `npm audit` instead of `aud`
|
|
48
69
|
|
|
70
|
+
## **6.12.5**
|
|
71
|
+
- [Fix] fix regressions from robustness refactor
|
|
72
|
+
- [actions] update reusable workflows
|
|
73
|
+
|
|
74
|
+
## **6.12.4**
|
|
75
|
+
- [Robustness] avoid `.push`, use `void`
|
|
76
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
77
|
+
- [readme] document that `addQueryPrefix` does not add `?` to empty output (#418)
|
|
78
|
+
- [readme] replace runkit CI badge with shields.io check-runs badge
|
|
79
|
+
- [actions] fix rebase workflow permissions
|
|
80
|
+
|
|
49
81
|
## **6.12.3**
|
|
50
82
|
- [Fix] `parse`: properly account for `strictNullHandling` when `allowEmptyArrays`
|
|
51
83
|
- [meta] fix changelog indentation
|
|
@@ -83,6 +115,17 @@
|
|
|
83
115
|
- [Dev Deps] pin `glob`, since v10.3.8+ requires a broken `jackspeak`
|
|
84
116
|
- [Dev Deps] pin `jackspeak` since 2.1.2+ depends on npm aliases, which kill the install process in npm < 6
|
|
85
117
|
|
|
118
|
+
## **6.11.4**
|
|
119
|
+
- [Fix] fix regressions from robustness refactor
|
|
120
|
+
- [actions] update reusable workflows
|
|
121
|
+
|
|
122
|
+
## **6.11.3**
|
|
123
|
+
- [Robustness] avoid `.push`, use `void`
|
|
124
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
125
|
+
- [readme] document that `addQueryPrefix` does not add `?` to empty output (#418)
|
|
126
|
+
- [readme] replace runkit CI badge with shields.io check-runs badge
|
|
127
|
+
- [actions] fix rebase workflow permissions
|
|
128
|
+
|
|
86
129
|
## **6.11.2**
|
|
87
130
|
- [Fix] `parse`: Fix parsing when the global Object prototype is frozen (#473)
|
|
88
131
|
- [Tests] add passing test cases with empty keys (#473)
|
|
@@ -100,6 +143,17 @@
|
|
|
100
143
|
- [New] [Fix] `stringify`: revert 0e903c0; add `commaRoundTrip` option (#442)
|
|
101
144
|
- [readme] fix version badge
|
|
102
145
|
|
|
146
|
+
## **6.10.7**
|
|
147
|
+
- [Fix] fix regressions from robustness refactor
|
|
148
|
+
- [actions] update reusable workflows
|
|
149
|
+
|
|
150
|
+
## **6.10.6**
|
|
151
|
+
- [Robustness] avoid `.push`, use `void`
|
|
152
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
153
|
+
- [readme] document that `addQueryPrefix` does not add `?` to empty output (#418)
|
|
154
|
+
- [readme] replace runkit CI badge with shields.io check-runs badge
|
|
155
|
+
- [actions] fix rebase workflow permissions
|
|
156
|
+
|
|
103
157
|
## **6.10.5**
|
|
104
158
|
- [Fix] `stringify`: with `arrayFormat: comma`, properly include an explicit `[]` on a single-item array (#434)
|
|
105
159
|
|
|
@@ -137,6 +191,18 @@
|
|
|
137
191
|
- [Tests] use `ljharb/actions/node/install` instead of `ljharb/actions/node/run`
|
|
138
192
|
- [Tests] Revert "[meta] ignore eclint transitive audit warning"
|
|
139
193
|
|
|
194
|
+
## **6.9.9**
|
|
195
|
+
- [Fix] fix regressions from robustness refactor
|
|
196
|
+
- [meta] add `npmignore` to autogenerate an npmignore file
|
|
197
|
+
- [actions] update reusable workflows
|
|
198
|
+
|
|
199
|
+
## **6.9.8**
|
|
200
|
+
- [Robustness] avoid `.push`, use `void`
|
|
201
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
202
|
+
- [readme] document that `addQueryPrefix` does not add `?` to empty output (#418)
|
|
203
|
+
- [readme] replace runkit CI badge with shields.io check-runs badge
|
|
204
|
+
- [actions] fix rebase workflow permissions
|
|
205
|
+
|
|
140
206
|
## **6.9.7**
|
|
141
207
|
- [Fix] `parse`: ignore `__proto__` keys (#428)
|
|
142
208
|
- [Fix] `stringify`: avoid encoding arrayformat comma when `encodeValuesOnly = true` (#424)
|
|
@@ -197,6 +263,18 @@
|
|
|
197
263
|
- [Tests] up to `node` `v12.10`, `v11.15`, `v10.16`, `v8.16`
|
|
198
264
|
- [Tests] `Buffer.from` in node v5.0-v5.9 and v4.0-v4.4 requires a TypedArray
|
|
199
265
|
|
|
266
|
+
## **6.8.5**
|
|
267
|
+
- [Fix] fix regressions from robustness refactor
|
|
268
|
+
- [meta] add `npmignore` to autogenerate an npmignore file
|
|
269
|
+
- [actions] update reusable workflows
|
|
270
|
+
|
|
271
|
+
## **6.8.4**
|
|
272
|
+
- [Robustness] avoid `.push`, use `void`
|
|
273
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
274
|
+
- [readme] document that `addQueryPrefix` does not add `?` to empty output (#418)
|
|
275
|
+
- [readme] replace runkit CI badge with shields.io check-runs badge
|
|
276
|
+
- [actions] fix rebase workflow permissions
|
|
277
|
+
|
|
200
278
|
## **6.8.3**
|
|
201
279
|
- [Fix] `parse`: ignore `__proto__` keys (#428)
|
|
202
280
|
- [Robustness] `stringify`: avoid relying on a global `undefined` (#427)
|
|
@@ -241,6 +319,18 @@
|
|
|
241
319
|
- [meta] add FUNDING.yml
|
|
242
320
|
- [meta] Clean up license text so it’s properly detected as BSD-3-Clause
|
|
243
321
|
|
|
322
|
+
## **6.7.5**
|
|
323
|
+
- [Fix] fix regressions from robustness refactor
|
|
324
|
+
- [meta] add `npmignore` to autogenerate an npmignore file
|
|
325
|
+
- [actions] update reusable workflows
|
|
326
|
+
|
|
327
|
+
## **6.7.4**
|
|
328
|
+
- [Robustness] avoid `.push`, use `void`
|
|
329
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
330
|
+
- [readme] document that `addQueryPrefix` does not add `?` to empty output (#418)
|
|
331
|
+
- [readme] replace runkit CI badge with shields.io check-runs badge
|
|
332
|
+
- [actions] fix rebase workflow permissions
|
|
333
|
+
|
|
244
334
|
## **6.7.3**
|
|
245
335
|
- [Fix] `parse`: ignore `__proto__` keys (#428)
|
|
246
336
|
- [Fix] `stringify`: avoid encoding arrayformat comma when `encodeValuesOnly = true` (#424)
|
|
@@ -292,6 +382,18 @@
|
|
|
292
382
|
- [Tests] fix Buffer tests to work in node < 4.5 and node < 5.10
|
|
293
383
|
- [Tests] temporarily allow coverage to fail
|
|
294
384
|
|
|
385
|
+
## **6.6.3**
|
|
386
|
+
- [Fix] fix regressions from robustness refactor
|
|
387
|
+
- [meta] add `npmignore` to autogenerate an npmignore file
|
|
388
|
+
- [actions] update reusable workflows
|
|
389
|
+
|
|
390
|
+
## **6.6.2**
|
|
391
|
+
- [Robustness] avoid `.push`, use `void`
|
|
392
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
393
|
+
- [readme] document that `addQueryPrefix` does not add `?` to empty output (#418)
|
|
394
|
+
- [readme] replace runkit CI badge with shields.io check-runs badge
|
|
395
|
+
- [actions] fix rebase workflow permissions
|
|
396
|
+
|
|
295
397
|
## **6.6.1**
|
|
296
398
|
- [Fix] `parse`: ignore `__proto__` keys (#428)
|
|
297
399
|
- [Fix] fix for an impossible situation: when the formatter is called with a non-string value
|
|
@@ -334,6 +436,18 @@
|
|
|
334
436
|
- [Dev Deps] update `browserify`, `eslint`, `@ljharb/eslint-config`, `iconv-lite`, `safe-publish-latest`, `tape`
|
|
335
437
|
- [Tests] up to `node` `v10.10`, `v9.11`, `v8.12`, `v6.14`, `v4.9`; pin included builds to LTS
|
|
336
438
|
|
|
439
|
+
## **6.5.5**
|
|
440
|
+
- [Fix] fix regressions from robustness refactor
|
|
441
|
+
- [meta] add `npmignore` to autogenerate an npmignore file
|
|
442
|
+
- [actions] update reusable workflows
|
|
443
|
+
|
|
444
|
+
## **6.5.4**
|
|
445
|
+
- [Robustness] avoid `.push`, use `void`
|
|
446
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
447
|
+
- [readme] document that `addQueryPrefix` does not add `?` to empty output (#418)
|
|
448
|
+
- [readme] replace runkit CI badge with shields.io check-runs badge
|
|
449
|
+
- [actions] fix rebase workflow permissions
|
|
450
|
+
|
|
337
451
|
## **6.5.3**
|
|
338
452
|
- [Fix] `parse`: ignore `__proto__` keys (#428)
|
|
339
453
|
- [Fix] `utils.merge`: avoid a crash with a null target and a truthy non-array source
|
|
@@ -384,6 +498,18 @@
|
|
|
384
498
|
- [Tests] up to `node` `v8.1`, `v7.10`, `v6.11`; npm v4.6 breaks on node < v1; npm v5+ breaks on node < v4
|
|
385
499
|
- [Tests] add `editorconfig-tools`
|
|
386
500
|
|
|
501
|
+
## **6.4.3**
|
|
502
|
+
- [Fix] fix regressions from robustness refactor
|
|
503
|
+
- [meta] add `npmignore` to autogenerate an npmignore file
|
|
504
|
+
- [actions] update reusable workflows
|
|
505
|
+
|
|
506
|
+
## **6.4.2**
|
|
507
|
+
- [Robustness] avoid `.push`, use `void`
|
|
508
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
509
|
+
- [readme] replace runkit CI badge with shields.io check-runs badge
|
|
510
|
+
- [readme] replace travis CI badge with shields.io check-runs badge
|
|
511
|
+
- [actions] fix rebase workflow permissions
|
|
512
|
+
|
|
387
513
|
## **6.4.1**
|
|
388
514
|
- [Fix] `parse`: ignore `__proto__` keys (#428)
|
|
389
515
|
- [Fix] fix for an impossible situation: when the formatter is called with a non-string value
|
|
@@ -414,6 +540,17 @@
|
|
|
414
540
|
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
|
|
415
541
|
- [eslint] reduce warnings
|
|
416
542
|
|
|
543
|
+
## **6.3.5**
|
|
544
|
+
- [Fix] fix regressions from robustness refactor
|
|
545
|
+
- [meta] add `npmignore` to autogenerate an npmignore file
|
|
546
|
+
- [actions] update reusable workflows
|
|
547
|
+
|
|
548
|
+
## **6.3.4**
|
|
549
|
+
- [Robustness] avoid `.push`, use `void`
|
|
550
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
551
|
+
- [readme] replace travis CI badge with shields.io check-runs badge
|
|
552
|
+
- [actions] fix rebase workflow permissions
|
|
553
|
+
|
|
417
554
|
## **6.3.3**
|
|
418
555
|
- [Fix] `parse`: ignore `__proto__` keys (#428)
|
|
419
556
|
- [Fix] fix for an impossible situation: when the formatter is called with a non-string value
|
|
@@ -467,6 +604,17 @@
|
|
|
467
604
|
- [Tests] skip Object.create tests when null objects are not available
|
|
468
605
|
- [Tests] Turn on eslint for test files (#175)
|
|
469
606
|
|
|
607
|
+
## **6.2.6**
|
|
608
|
+
- [Fix] fix regression from robustness refactor
|
|
609
|
+
- [meta] add `npmignore` to autogenerate an npmignore file
|
|
610
|
+
- [actions] update reusable workflows
|
|
611
|
+
|
|
612
|
+
## **6.2.5**
|
|
613
|
+
- [Robustness] avoid `.push`, use `void`
|
|
614
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
615
|
+
- [readme] replace travis CI badge with shields.io check-runs badge
|
|
616
|
+
- [actions] fix rebase workflow permissions
|
|
617
|
+
|
|
470
618
|
## **6.2.4**
|
|
471
619
|
- [Fix] `parse`: ignore `__proto__` keys (#428)
|
|
472
620
|
- [Fix] `utils.merge`: avoid a crash with a null target and an array source
|
|
@@ -505,6 +653,16 @@
|
|
|
505
653
|
- [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160)
|
|
506
654
|
- [Fix] fix compacting of nested sparse arrays (#150)
|
|
507
655
|
|
|
656
|
+
## **6.1.4**
|
|
657
|
+
- [Fix] fix regression from robustness refactor
|
|
658
|
+
- [meta] add `npmignore` to autogenerate an npmignore file
|
|
659
|
+
- [actions] update reusable workflows
|
|
660
|
+
|
|
661
|
+
## **6.1.3**
|
|
662
|
+
- [Robustness] avoid `.push`, use `void`
|
|
663
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
664
|
+
- [readme] replace travis CI badge with shields.io check-runs badge
|
|
665
|
+
|
|
508
666
|
## **6.1.2**
|
|
509
667
|
- [Fix] follow `allowPrototypes` option during merge (#201, #200)
|
|
510
668
|
- [Fix] chmod a-x
|
|
@@ -519,6 +677,16 @@
|
|
|
519
677
|
- [Fix] "sort" option should work at a depth of 3 or more (#151)
|
|
520
678
|
- [Fix] Restore `dist` directory; will be removed in v7 (#148)
|
|
521
679
|
|
|
680
|
+
## **6.0.6**
|
|
681
|
+
- [Fix] fix regression from robustness refactor
|
|
682
|
+
- [meta] add `npmignore` to autogenerate an npmignore file
|
|
683
|
+
- [actions] update reusable workflows
|
|
684
|
+
|
|
685
|
+
## **6.0.5**
|
|
686
|
+
- [Robustness] avoid `.push`, use `void`
|
|
687
|
+
- [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
|
|
688
|
+
- [readme] replace travis CI badge with shields.io check-runs badge
|
|
689
|
+
|
|
522
690
|
## **6.0.4**
|
|
523
691
|
- [Fix] follow `allowPrototypes` option during merge (#201, #200)
|
|
524
692
|
- [Fix] chmod a-x
|
package/README.md
CHANGED
|
@@ -197,6 +197,11 @@ assert.deepEqual(qs.parse('foo=bar&foo=baz', { duplicates: 'first' }), { foo: 'b
|
|
|
197
197
|
assert.deepEqual(qs.parse('foo=bar&foo=baz', { duplicates: 'last' }), { foo: 'baz' });
|
|
198
198
|
```
|
|
199
199
|
|
|
200
|
+
Note that keys with bracket notation (`[]`) always combine into arrays, regardless of the `duplicates` setting:
|
|
201
|
+
```javascript
|
|
202
|
+
assert.deepEqual(qs.parse('a=1&a=2&b[]=1&b[]=2', { duplicates: 'last' }), { a: '2', b: ['1', '2'] });
|
|
203
|
+
```
|
|
204
|
+
|
|
200
205
|
If you have to deal with legacy browsers or services, there's also support for decoding percent-encoded octets as iso-8859-1:
|
|
201
206
|
|
|
202
207
|
```javascript
|
|
@@ -325,6 +330,19 @@ var mixedNotation = qs.parse('a[0]=b&a[b]=c');
|
|
|
325
330
|
assert.deepEqual(mixedNotation, { a: { '0': 'b', b: 'c' } });
|
|
326
331
|
```
|
|
327
332
|
|
|
333
|
+
When a key appears as both a plain value and an object, **qs** will by default wrap the conflicting values in an array (`strictMerge` defaults to `true`):
|
|
334
|
+
|
|
335
|
+
```javascript
|
|
336
|
+
assert.deepEqual(qs.parse('a[b]=c&a=d'), { a: [{ b: 'c' }, 'd'] });
|
|
337
|
+
assert.deepEqual(qs.parse('a=d&a[b]=c'), { a: ['d', { b: 'c' }] });
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
To restore the legacy behavior (where the primitive is used as a key with value `true`), set `strictMerge` to `false`:
|
|
341
|
+
|
|
342
|
+
```javascript
|
|
343
|
+
assert.deepEqual(qs.parse('a[b]=c&a=d', { strictMerge: false }), { a: { b: 'c', d: true } });
|
|
344
|
+
```
|
|
345
|
+
|
|
328
346
|
You can also create arrays of objects:
|
|
329
347
|
|
|
330
348
|
```javascript
|
package/dist/qs.js
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
"use strict";var stringify=require(4),parse=require(3),formats=require(1);module.exports={formats:formats,parse:parse,stringify:stringify};
|
|
6
6
|
|
|
7
7
|
},{"1":1,"3":3,"4":4}],3:[function(require,module,exports){
|
|
8
|
-
"use strict";var utils=require(5),has=Object.prototype.hasOwnProperty,isArray=Array.isArray,defaults={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:utils.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},interpretNumericEntities=function(e){return e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},parseArrayValue=function(e,t,r){if(e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1)return e.split(",");if(t.throwOnLimitExceeded&&r>=t.arrayLimit)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(1===t.arrayLimit?"":"s")+" allowed in an array.");return e},isoSentinel="utf8=%26%2310003%3B",charsetSentinel="utf8=%E2%9C%93",parseValues=function parseQueryStringValues(e,t){var r={__proto__:null},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e;i=i.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var a=t.parameterLimit===1/0?void 0:t.parameterLimit,o=i.split(t.delimiter,t.throwOnLimitExceeded?a+1:a);if(t.throwOnLimitExceeded&&o.length>a)throw new RangeError("Parameter limit exceeded. Only "+a+" parameter"+(1===a?"":"s")+" allowed.");var l,n=-1,s=t.charset;if(t.charsetSentinel)for(l=0;l<o.length;++l)0===o[l].indexOf("utf8=")&&(o[l]===charsetSentinel?s="utf-8":o[l]===isoSentinel&&(s="iso-8859-1"),n=l,l=o.length);for(l=0;l<o.length;++l)if(l!==n){var d,p
|
|
8
|
+
"use strict";var utils=require(5),has=Object.prototype.hasOwnProperty,isArray=Array.isArray,defaults={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:utils.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictMerge:!0,strictNullHandling:!1,throwOnLimitExceeded:!1},interpretNumericEntities=function(e){return e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},parseArrayValue=function(e,t,r){if(e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1)return e.split(",");if(t.throwOnLimitExceeded&&r>=t.arrayLimit)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(1===t.arrayLimit?"":"s")+" allowed in an array.");return e},isoSentinel="utf8=%26%2310003%3B",charsetSentinel="utf8=%E2%9C%93",parseValues=function parseQueryStringValues(e,t){var r={__proto__:null},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e;i=i.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var a=t.parameterLimit===1/0?void 0:t.parameterLimit,o=i.split(t.delimiter,t.throwOnLimitExceeded&&void 0!==a?a+1:a);if(t.throwOnLimitExceeded&&void 0!==a&&o.length>a)throw new RangeError("Parameter limit exceeded. Only "+a+" parameter"+(1===a?"":"s")+" allowed.");var l,n=-1,s=t.charset;if(t.charsetSentinel)for(l=0;l<o.length;++l)0===o[l].indexOf("utf8=")&&(o[l]===charsetSentinel?s="utf-8":o[l]===isoSentinel&&(s="iso-8859-1"),n=l,l=o.length);for(l=0;l<o.length;++l)if(l!==n){var d,c,p=o[l],u=p.indexOf("]="),y=-1===u?p.indexOf("="):u+1;if(-1===y?(d=t.decoder(p,defaults.decoder,s,"key"),c=t.strictNullHandling?null:""):null!==(d=t.decoder(p.slice(0,y),defaults.decoder,s,"key"))&&(c=utils.maybeMap(parseArrayValue(p.slice(y+1),t,isArray(r[d])?r[d].length:0),function(e){return t.decoder(e,defaults.decoder,s,"value")})),c&&t.interpretNumericEntities&&"iso-8859-1"===s&&(c=interpretNumericEntities(String(c))),p.indexOf("[]=")>-1&&(c=isArray(c)?[c]:c),t.comma&&isArray(c)&&c.length>t.arrayLimit){if(t.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(1===t.arrayLimit?"":"s")+" allowed in an array.");c=utils.combine([],c,t.arrayLimit,t.plainObjects)}if(null!==d){var f=has.call(r,d);f&&("combine"===t.duplicates||p.indexOf("[]=")>-1)?r[d]=utils.combine(r[d],c,t.arrayLimit,t.plainObjects):f&&"last"!==t.duplicates||(r[d]=c)}}return r},parseObject=function(e,t,r,i){var a=0;if(e.length>0&&"[]"===e[e.length-1]){var o=e.slice(0,-1).join("");a=Array.isArray(t)&&t[o]?t[o].length:0}for(var l=i?t:parseArrayValue(t,r,a),n=e.length-1;n>=0;--n){var s,d=e[n];if("[]"===d&&r.parseArrays)s=utils.isOverflow(l)?l:r.allowEmptyArrays&&(""===l||r.strictNullHandling&&null===l)?[]:utils.combine([],l,r.arrayLimit,r.plainObjects);else{s=r.plainObjects?{__proto__:null}:{};var c="["===d.charAt(0)&&"]"===d.charAt(d.length-1)?d.slice(1,-1):d,p=r.decodeDotInKeys?c.replace(/%2E/g,"."):c,u=parseInt(p,10),y=!isNaN(u)&&d!==p&&String(u)===p&&u>=0&&r.parseArrays;if(r.parseArrays||""!==p)if(y&&u<r.arrayLimit)(s=[])[u]=l;else{if(y&&r.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+r.arrayLimit+" element"+(1===r.arrayLimit?"":"s")+" allowed in an array.");y?(s[u]=l,utils.markOverflow(s,u)):"__proto__"!==p&&(s[p]=l)}else s={0:l}}l=s}return l},splitKeyIntoSegments=function splitKeyIntoSegments(e,t){var r=t.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e;if(t.depth<=0){if(!t.plainObjects&&has.call(Object.prototype,r)&&!t.allowPrototypes)return;return[r]}var i=/(\[[^[\]]*])/g,a=/(\[[^[\]]*])/.exec(r),o=a?r.slice(0,a.index):r,l=[];if(o){if(!t.plainObjects&&has.call(Object.prototype,o)&&!t.allowPrototypes)return;l[l.length]=o}for(var n=0;null!==(a=i.exec(r))&&n<t.depth;){n+=1;var s=a[1].slice(1,-1);if(!t.plainObjects&&has.call(Object.prototype,s)&&!t.allowPrototypes)return;l[l.length]=a[1]}if(a){if(!0===t.strictDepth)throw new RangeError("Input depth exceeded depth option of "+t.depth+" and strictDepth is true");l[l.length]="["+r.slice(a.index)+"]"}return l},parseKeys=function parseQueryStringKeys(e,t,r,i){if(e){var a=splitKeyIntoSegments(e,r);if(a)return parseObject(a,t,r,i)}},normalizeParseOptions=function normalizeParseOptions(e){if(!e)return defaults;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.decodeDotInKeys&&"boolean"!=typeof e.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0!==e.throwOnLimitExceeded&&"boolean"!=typeof e.throwOnLimitExceeded)throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var t=void 0===e.charset?defaults.charset:e.charset,r=void 0===e.duplicates?defaults.duplicates:e.duplicates;if("combine"!==r&&"first"!==r&&"last"!==r)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===e.allowDots?!0===e.decodeDotInKeys||defaults.allowDots:!!e.allowDots,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:defaults.allowEmptyArrays,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:defaults.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:defaults.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:defaults.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:defaults.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:defaults.comma,decodeDotInKeys:"boolean"==typeof e.decodeDotInKeys?e.decodeDotInKeys:defaults.decodeDotInKeys,decoder:"function"==typeof e.decoder?e.decoder:defaults.decoder,delimiter:"string"==typeof e.delimiter||utils.isRegExp(e.delimiter)?e.delimiter:defaults.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:defaults.depth,duplicates:r,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:defaults.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:defaults.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:defaults.plainObjects,strictDepth:"boolean"==typeof e.strictDepth?!!e.strictDepth:defaults.strictDepth,strictMerge:"boolean"==typeof e.strictMerge?!!e.strictMerge:defaults.strictMerge,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:defaults.strictNullHandling,throwOnLimitExceeded:"boolean"==typeof e.throwOnLimitExceeded&&e.throwOnLimitExceeded}};module.exports=function(e,t){var r=normalizeParseOptions(t);if(""===e||null==e)return r.plainObjects?{__proto__:null}:{};for(var i="string"==typeof e?parseValues(e,r):e,a=r.plainObjects?{__proto__:null}:{},o=Object.keys(i),l=0;l<o.length;++l){var n=o[l],s=parseKeys(n,i[n],r,"string"==typeof e);a=utils.merge(a,s,r)}return!0===r.allowSparse?a:utils.compact(a)};
|
|
9
9
|
|
|
10
10
|
},{"5":5}],4:[function(require,module,exports){
|
|
11
11
|
"use strict";var getSideChannel=require(46),utils=require(5),formats=require(1),has=Object.prototype.hasOwnProperty,arrayPrefixGenerators={brackets:function brackets(e){return e+"[]"},comma:"comma",indices:function indices(e,r){return e+"["+r+"]"},repeat:function repeat(e){return e}},isArray=Array.isArray,push=Array.prototype.push,pushToArray=function(e,r){push.apply(e,isArray(r)?r:[r])},toISO=Date.prototype.toISOString,defaultFormat=formats.default,defaults={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:utils.encode,encodeValuesOnly:!1,filter:void 0,format:defaultFormat,formatter:formats.formatters[defaultFormat],indices:!1,serializeDate:function serializeDate(e){return toISO.call(e)},skipNulls:!1,strictNullHandling:!1},isNonNullishPrimitive=function isNonNullishPrimitive(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||"symbol"==typeof e||"bigint"==typeof e},sentinel={},stringify=function stringify(e,r,t,o,a,n,i,l,s,f,u,d,y,c,p,m,h,v){for(var g=e,w=v,b=0,A=!1;void 0!==(w=w.get(sentinel))&&!A;){var D=w.get(e);if(b+=1,void 0!==D){if(D===b)throw new RangeError("Cyclic object value");A=!0}void 0===w.get(sentinel)&&(b=0)}if("function"==typeof f?g=f(r,g):g instanceof Date?g=y(g):"comma"===t&&isArray(g)&&(g=utils.maybeMap(g,function(e){return e instanceof Date?y(e):e})),null===g){if(n)return s&&!m?s(r,defaults.encoder,h,"key",c):r;g=""}if(isNonNullishPrimitive(g)||utils.isBuffer(g))return s?[p(m?r:s(r,defaults.encoder,h,"key",c))+"="+p(s(g,defaults.encoder,h,"value",c))]:[p(r)+"="+p(String(g))];var S,E=[];if(void 0===g)return E;if("comma"===t&&isArray(g))m&&s&&(g=utils.maybeMap(g,s)),S=[{value:g.length>0?g.join(",")||null:void 0}];else if(isArray(f))S=f;else{var N=Object.keys(g);S=u?N.sort(u):N}var T=l?String(r).replace(/\./g,"%2E"):String(r),O=o&&isArray(g)&&1===g.length?T+"[]":T;if(a&&isArray(g)&&0===g.length)return O+"[]";for(var k=0;k<S.length;++k){var I=S[k],P="object"==typeof I&&I&&void 0!==I.value?I.value:g[I];if(!i||null!==P){var x=d&&l?String(I).replace(/\./g,"%2E"):String(I),z=isArray(g)?"function"==typeof t?t(O,x):O:O+(d?"."+x:"["+x+"]");v.set(e,b);var K=getSideChannel();K.set(sentinel,v),pushToArray(E,stringify(P,z,t,o,a,n,i,l,"comma"===t&&m&&isArray(g)?null:s,f,u,d,y,c,p,m,h,K))}}return E},normalizeStringifyOptions=function normalizeStringifyOptions(e){if(!e)return defaults;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var r=e.charset||defaults.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=formats.default;if(void 0!==e.format){if(!has.call(formats.formatters,e.format))throw new TypeError("Unknown format option provided.");t=e.format}var o,a=formats.formatters[t],n=defaults.filter;if(("function"==typeof e.filter||isArray(e.filter))&&(n=e.filter),o=e.arrayFormat in arrayPrefixGenerators?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":defaults.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var i=void 0===e.allowDots?!0===e.encodeDotInKeys||defaults.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:defaults.addQueryPrefix,allowDots:i,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:defaults.allowEmptyArrays,arrayFormat:o,charset:r,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:defaults.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?defaults.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:defaults.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:defaults.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:defaults.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:defaults.encodeValuesOnly,filter:n,format:t,formatter:a,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:defaults.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:defaults.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:defaults.strictNullHandling}};module.exports=function(e,r){var t,o=e,a=normalizeStringifyOptions(r);"function"==typeof a.filter?o=(0,a.filter)("",o):isArray(a.filter)&&(t=a.filter);var n=[];if("object"!=typeof o||null===o)return"";var i=arrayPrefixGenerators[a.arrayFormat],l="comma"===i&&a.commaRoundTrip;t||(t=Object.keys(o)),a.sort&&t.sort(a.sort);for(var s=getSideChannel(),f=0;f<t.length;++f){var u=t[f],d=o[u];a.skipNulls&&null===d||pushToArray(n,stringify(d,u,i,l,a.allowEmptyArrays,a.strictNullHandling,a.skipNulls,a.encodeDotInKeys,a.encode?a.encoder:null,a.filter,a.sort,a.allowDots,a.serializeDate,a.format,a.formatter,a.encodeValuesOnly,a.charset,s))}var y=n.join(a.delimiter),c=!0===a.addQueryPrefix?"?":"";return a.charsetSentinel&&("iso-8859-1"===a.charset?c+="utf8=%26%2310003%3B&":c+="utf8=%E2%9C%93&"),y.length>0?c+y:""};
|
|
12
12
|
|
|
13
13
|
},{"1":1,"46":46,"5":5}],5:[function(require,module,exports){
|
|
14
|
-
"use strict";var formats=require(1),getSideChannel=require(46),has=Object.prototype.hasOwnProperty,isArray=Array.isArray,overflowChannel=getSideChannel(),markOverflow=function markOverflow(e,r){return overflowChannel.set(e,r),e},isOverflow=function isOverflow(e){return overflowChannel.has(e)},getMaxIndex=function getMaxIndex(e){return overflowChannel.get(e)},setMaxIndex=function setMaxIndex(e,r){overflowChannel.set(e,r)},hexTable=function(){for(var e=[],r=0;r<256;++r)e[e.length]="%"+((r<16?"0":"")+r.toString(16)).toUpperCase();return e}(),compactQueue=function compactQueue(e){for(;e.length>1;){var r=e.pop(),t=r.obj[r.prop];if(isArray(t)){for(var n=[],o=0;o<t.length;++o)void 0!==t[o]&&(n[n.length]=t[o]);r.obj[r.prop]=n}}},arrayToObject=function arrayToObject(e,r){for(var t=r&&r.plainObjects?{__proto__:null}:{},n=0;n<e.length;++n)void 0!==e[n]&&(t[n]=e[n]);return t},merge=function merge(e,r,t){if(!r)return e;if("object"!=typeof r&&"function"!=typeof r){if(isArray(e)){var n=e.length;if(t&&"number"==typeof t.arrayLimit&&n>t.arrayLimit)return markOverflow(arrayToObject(e.concat(r),t),n);e[n]=r}else{if(!e||"object"!=typeof e)return[e,r];if(isOverflow(e)){var o=getMaxIndex(e)+1;e[o]=r,setMaxIndex(e,o)}else(t&&(t.plainObjects||t.allowPrototypes)||!has.call(Object.prototype,r))&&(e[r]=!0)}return e}if(!e||"object"!=typeof e){if(isOverflow(r)){for(var a=Object.keys(r),i=t&&t.plainObjects?{__proto__:null,0:e}:{0:e},c=0;c<a.length;c++)i[parseInt(a[c],10)+1]=r[a[c]];return markOverflow(i,getMaxIndex(r)+1)}var l=[e].concat(r);return t&&"number"==typeof t.arrayLimit&&l.length>t.arrayLimit?markOverflow(arrayToObject(l,t),l.length-1):l}var f=e;return isArray(e)&&!isArray(r)&&(f=arrayToObject(e,t)),isArray(e)&&isArray(r)?(r.forEach(function(r,n){if(has.call(e,n)){var o=e[n];o&&"object"==typeof o&&r&&"object"==typeof r?e[n]=merge(o,r,t):e[e.length]=r}else e[n]=r}),e):Object.keys(r).reduce(function(e,n){var o=r[n];if(has.call(e,n)?e[n]=merge(e[n],o,t):e[n]=o,isOverflow(r)&&!isOverflow(e)&&markOverflow(e,getMaxIndex(r)),isOverflow(e)){var a=parseInt(n,10);String(a)===n&&a>=0&&a>getMaxIndex(e)&&setMaxIndex(e,a)}return e},f)},assign=function assignSingleSource(e,r){return Object.keys(r).reduce(function(e,t){return e[t]=r[t],e},e)},decode=function(e,r,t){var n=e.replace(/\+/g," ");if("iso-8859-1"===t)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(e){return n}},limit=1024,encode=function encode(e,r,t,n,o){if(0===e.length)return e;var a=e;if("symbol"==typeof e?a=Symbol.prototype.toString.call(e):"string"!=typeof e&&(a=String(e)),"iso-8859-1"===t)return escape(a).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});for(var i="",c=0;c<a.length;c+=limit){for(var l=a.length>=limit?a.slice(c,c+limit):a,f=[],s=0;s<l.length;++s){var u=l.charCodeAt(s);45===u||46===u||95===u||126===u||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===formats.RFC1738&&(40===u||41===u)?f[f.length]=l.charAt(s):u<128?f[f.length]=hexTable[u]:u<2048?f[f.length]=hexTable[192|u>>6]+hexTable[128|63&u]:u<55296||u>=57344?f[f.length]=hexTable[224|u>>12]+hexTable[128|u>>6&63]+hexTable[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&l.charCodeAt(s)),f[f.length]=hexTable[240|u>>18]+hexTable[128|u>>12&63]+hexTable[128|u>>6&63]+hexTable[128|63&u])}i+=f.join("")}return i},compact=function compact(e){for(var r=[{obj:{o:e},prop:"o"}],t=[],n=0;n<r.length;++n)for(var o=r[n],a=o.obj[o.prop],i=Object.keys(a),c=0;c<i.length;++c){var l=i[c],f=a[l];"object"==typeof f&&null!==f&&-1===t.indexOf(f)&&(r[r.length]={obj:a,prop:l},t[t.length]=f)}return compactQueue(r),e},isRegExp=function isRegExp(e){return"[object RegExp]"===Object.prototype.toString.call(e)},isBuffer=function isBuffer(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))},combine=function combine(e,r,t,n){if(isOverflow(e)){var o=getMaxIndex(e)+1;return e[o]=r,setMaxIndex(e,o),e}var a=[].concat(e,r);return a.length>t?markOverflow(arrayToObject(a,{plainObjects:n}),a.length-1):a},maybeMap=function maybeMap(e,r){if(isArray(e)){for(var t=[],n=0;n<e.length;n+=1)t[t.length]=r(e[n]);return t}return r(e)};module.exports={/* common-shake removed: arrayToObject:arrayToObject *//* common-shake removed: assign:assign */combine:combine,compact:compact,decode:decode,encode:encode,isBuffer:isBuffer,isOverflow:isOverflow,isRegExp:isRegExp,markOverflow:markOverflow,maybeMap:maybeMap,merge:merge};
|
|
14
|
+
"use strict";var formats=require(1),getSideChannel=require(46),has=Object.prototype.hasOwnProperty,isArray=Array.isArray,overflowChannel=getSideChannel(),markOverflow=function markOverflow(e,r){return overflowChannel.set(e,r),e},isOverflow=function isOverflow(e){return overflowChannel.has(e)},getMaxIndex=function getMaxIndex(e){return overflowChannel.get(e)},setMaxIndex=function setMaxIndex(e,r){overflowChannel.set(e,r)},hexTable=function(){for(var e=[],r=0;r<256;++r)e[e.length]="%"+((r<16?"0":"")+r.toString(16)).toUpperCase();return e}(),compactQueue=function compactQueue(e){for(;e.length>1;){var r=e.pop(),t=r.obj[r.prop];if(isArray(t)){for(var n=[],o=0;o<t.length;++o)void 0!==t[o]&&(n[n.length]=t[o]);r.obj[r.prop]=n}}},arrayToObject=function arrayToObject(e,r){for(var t=r&&r.plainObjects?{__proto__:null}:{},n=0;n<e.length;++n)void 0!==e[n]&&(t[n]=e[n]);return t},merge=function merge(e,r,t){if(!r)return e;if("object"!=typeof r&&"function"!=typeof r){if(isArray(e)){var n=e.length;if(t&&"number"==typeof t.arrayLimit&&n>t.arrayLimit)return markOverflow(arrayToObject(e.concat(r),t),n);e[n]=r}else{if(!e||"object"!=typeof e)return[e,r];if(isOverflow(e)){var o=getMaxIndex(e)+1;e[o]=r,setMaxIndex(e,o)}else{if(t&&t.strictMerge)return[e,r];(t&&(t.plainObjects||t.allowPrototypes)||!has.call(Object.prototype,r))&&(e[r]=!0)}}return e}if(!e||"object"!=typeof e){if(isOverflow(r)){for(var a=Object.keys(r),i=t&&t.plainObjects?{__proto__:null,0:e}:{0:e},c=0;c<a.length;c++)i[parseInt(a[c],10)+1]=r[a[c]];return markOverflow(i,getMaxIndex(r)+1)}var l=[e].concat(r);return t&&"number"==typeof t.arrayLimit&&l.length>t.arrayLimit?markOverflow(arrayToObject(l,t),l.length-1):l}var f=e;return isArray(e)&&!isArray(r)&&(f=arrayToObject(e,t)),isArray(e)&&isArray(r)?(r.forEach(function(r,n){if(has.call(e,n)){var o=e[n];o&&"object"==typeof o&&r&&"object"==typeof r?e[n]=merge(o,r,t):e[e.length]=r}else e[n]=r}),e):Object.keys(r).reduce(function(e,n){var o=r[n];if(has.call(e,n)?e[n]=merge(e[n],o,t):e[n]=o,isOverflow(r)&&!isOverflow(e)&&markOverflow(e,getMaxIndex(r)),isOverflow(e)){var a=parseInt(n,10);String(a)===n&&a>=0&&a>getMaxIndex(e)&&setMaxIndex(e,a)}return e},f)},assign=function assignSingleSource(e,r){return Object.keys(r).reduce(function(e,t){return e[t]=r[t],e},e)},decode=function(e,r,t){var n=e.replace(/\+/g," ");if("iso-8859-1"===t)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(e){return n}},limit=1024,encode=function encode(e,r,t,n,o){if(0===e.length)return e;var a=e;if("symbol"==typeof e?a=Symbol.prototype.toString.call(e):"string"!=typeof e&&(a=String(e)),"iso-8859-1"===t)return escape(a).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});for(var i="",c=0;c<a.length;c+=limit){for(var l=a.length>=limit?a.slice(c,c+limit):a,f=[],s=0;s<l.length;++s){var u=l.charCodeAt(s);45===u||46===u||95===u||126===u||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===formats.RFC1738&&(40===u||41===u)?f[f.length]=l.charAt(s):u<128?f[f.length]=hexTable[u]:u<2048?f[f.length]=hexTable[192|u>>6]+hexTable[128|63&u]:u<55296||u>=57344?f[f.length]=hexTable[224|u>>12]+hexTable[128|u>>6&63]+hexTable[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&l.charCodeAt(s)),f[f.length]=hexTable[240|u>>18]+hexTable[128|u>>12&63]+hexTable[128|u>>6&63]+hexTable[128|63&u])}i+=f.join("")}return i},compact=function compact(e){for(var r=[{obj:{o:e},prop:"o"}],t=[],n=0;n<r.length;++n)for(var o=r[n],a=o.obj[o.prop],i=Object.keys(a),c=0;c<i.length;++c){var l=i[c],f=a[l];"object"==typeof f&&null!==f&&-1===t.indexOf(f)&&(r[r.length]={obj:a,prop:l},t[t.length]=f)}return compactQueue(r),e},isRegExp=function isRegExp(e){return"[object RegExp]"===Object.prototype.toString.call(e)},isBuffer=function isBuffer(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))},combine=function combine(e,r,t,n){if(isOverflow(e)){var o=getMaxIndex(e)+1;return e[o]=r,setMaxIndex(e,o),e}var a=[].concat(e,r);return a.length>t?markOverflow(arrayToObject(a,{plainObjects:n}),a.length-1):a},maybeMap=function maybeMap(e,r){if(isArray(e)){for(var t=[],n=0;n<e.length;n+=1)t[t.length]=r(e[n]);return t}return r(e)};module.exports={/* common-shake removed: arrayToObject:arrayToObject *//* common-shake removed: assign:assign */combine:combine,compact:compact,decode:decode,encode:encode,isBuffer:isBuffer,isOverflow:isOverflow,isRegExp:isRegExp,markOverflow:markOverflow,maybeMap:maybeMap,merge:merge};
|
|
15
15
|
|
|
16
16
|
},{"1":1,"46":46}],46:[function(require,module,exports){
|
|
17
17
|
"use strict";var $TypeError=require(20),inspect=require(42),getSideChannelList=require(43),getSideChannelMap=require(44),getSideChannelWeakMap=require(45),makeChannel=getSideChannelWeakMap||getSideChannelMap||getSideChannelList;module.exports=function getSideChannel(){var e,n={assert:function(e){if(!n.has(e))throw new $TypeError("Side channel does not contain "+inspect(e))},delete:function(n){return!!e&&e.delete(n)},get:function(n){return e&&e.get(n)},has:function(n){return!!e&&e.has(n)},set:function(n,t){e||(e=makeChannel()),e.set(n,t)}};return n};
|
|
@@ -78,20 +78,20 @@
|
|
|
78
78
|
},{}],23:[function(require,module,exports){
|
|
79
79
|
"use strict";var ERROR_MESSAGE="Function.prototype.bind called on incompatible ",toStr=Object.prototype.toString,max=Math.max,funcType="[object Function]",concatty=function concatty(t,n){for(var r=[],o=0;o<t.length;o+=1)r[o]=t[o];for(var e=0;e<n.length;e+=1)r[e+t.length]=n[e];return r},slicy=function slicy(t,n){for(var r=[],o=n||0,e=0;o<t.length;o+=1,e+=1)r[e]=t[o];return r},joiny=function(t,n){for(var r="",o=0;o<t.length;o+=1)r+=t[o],o+1<t.length&&(r+=n);return r};module.exports=function bind(t){var n=this;if("function"!=typeof n||toStr.apply(n)!==funcType)throw new TypeError(ERROR_MESSAGE+n);for(var r,o=slicy(arguments,1),e=max(0,n.length-o.length),i=[],c=0;c<e;c++)i[c]="$"+c;if(r=Function("binder","return function ("+joiny(i,",")+"){ return binder.apply(this,arguments); }")(function(){if(this instanceof r){var e=n.apply(this,concatty(o,arguments));return Object(e)===e?e:this}return n.apply(t,concatty(o,arguments))}),n.prototype){var p=function Empty(){};p.prototype=n.prototype,r.prototype=new p,p.prototype=null}return r};
|
|
80
80
|
|
|
81
|
-
},{}],
|
|
82
|
-
"use strict";module.exports=Math.
|
|
81
|
+
},{}],35:[function(require,module,exports){
|
|
82
|
+
"use strict";module.exports=Math.floor;
|
|
83
83
|
|
|
84
84
|
},{}],37:[function(require,module,exports){
|
|
85
85
|
"use strict";module.exports=Math.max;
|
|
86
86
|
|
|
87
|
-
},{}],34:[function(require,module,exports){
|
|
88
|
-
"use strict";module.exports=Math.abs;
|
|
89
|
-
|
|
90
87
|
},{}],38:[function(require,module,exports){
|
|
91
88
|
"use strict";module.exports=Math.min;
|
|
92
89
|
|
|
93
|
-
},{}],
|
|
94
|
-
"use strict";module.exports=Math.
|
|
90
|
+
},{}],34:[function(require,module,exports){
|
|
91
|
+
"use strict";module.exports=Math.abs;
|
|
92
|
+
|
|
93
|
+
},{}],39:[function(require,module,exports){
|
|
94
|
+
"use strict";module.exports=Math.pow;
|
|
95
95
|
|
|
96
96
|
},{}],40:[function(require,module,exports){
|
|
97
97
|
"use strict";module.exports=Math.round;
|
package/lib/parse.js
CHANGED
|
@@ -25,6 +25,7 @@ var defaults = {
|
|
|
25
25
|
parseArrays: true,
|
|
26
26
|
plainObjects: false,
|
|
27
27
|
strictDepth: false,
|
|
28
|
+
strictMerge: true,
|
|
28
29
|
strictNullHandling: false,
|
|
29
30
|
throwOnLimitExceeded: false
|
|
30
31
|
};
|
|
@@ -66,10 +67,10 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
66
67
|
var limit = options.parameterLimit === Infinity ? void undefined : options.parameterLimit;
|
|
67
68
|
var parts = cleanStr.split(
|
|
68
69
|
options.delimiter,
|
|
69
|
-
options.throwOnLimitExceeded ? limit + 1 : limit
|
|
70
|
+
options.throwOnLimitExceeded && typeof limit !== 'undefined' ? limit + 1 : limit
|
|
70
71
|
);
|
|
71
72
|
|
|
72
|
-
if (options.throwOnLimitExceeded && parts.length > limit) {
|
|
73
|
+
if (options.throwOnLimitExceeded && typeof limit !== 'undefined' && parts.length > limit) {
|
|
73
74
|
throw new RangeError('Parameter limit exceeded. Only ' + limit + ' parameter' + (limit === 1 ? '' : 's') + ' allowed.');
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -139,7 +140,7 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
139
140
|
|
|
140
141
|
if (key !== null) {
|
|
141
142
|
var existing = has.call(obj, key);
|
|
142
|
-
if (existing && options.duplicates === 'combine') {
|
|
143
|
+
if (existing && (options.duplicates === 'combine' || part.indexOf('[]=') > -1)) {
|
|
143
144
|
obj[key] = utils.combine(
|
|
144
145
|
obj[key],
|
|
145
146
|
val,
|
|
@@ -339,6 +340,7 @@ var normalizeParseOptions = function normalizeParseOptions(opts) {
|
|
|
339
340
|
parseArrays: opts.parseArrays !== false,
|
|
340
341
|
plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
|
|
341
342
|
strictDepth: typeof opts.strictDepth === 'boolean' ? !!opts.strictDepth : defaults.strictDepth,
|
|
343
|
+
strictMerge: typeof opts.strictMerge === 'boolean' ? !!opts.strictMerge : defaults.strictMerge,
|
|
342
344
|
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling,
|
|
343
345
|
throwOnLimitExceeded: typeof opts.throwOnLimitExceeded === 'boolean' ? opts.throwOnLimitExceeded : false
|
|
344
346
|
};
|
package/lib/utils.js
CHANGED
|
@@ -85,6 +85,8 @@ var merge = function merge(target, source, options) {
|
|
|
85
85
|
var newIndex = getMaxIndex(target) + 1;
|
|
86
86
|
target[newIndex] = source;
|
|
87
87
|
setMaxIndex(target, newIndex);
|
|
88
|
+
} else if (options && options.strictMerge) {
|
|
89
|
+
return [target, source];
|
|
88
90
|
} else if (
|
|
89
91
|
(options && (options.plainObjects || options.allowPrototypes))
|
|
90
92
|
|| !has.call(Object.prototype, source)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "qs",
|
|
3
3
|
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
|
|
4
4
|
"homepage": "https://github.com/ljharb/qs",
|
|
5
|
-
"version": "6.
|
|
5
|
+
"version": "6.15.1",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/ljharb/qs.git"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@browserify/envify": "^6.0.0",
|
|
38
38
|
"@browserify/uglifyify": "^6.0.0",
|
|
39
|
-
"@ljharb/eslint-config": "^22.
|
|
39
|
+
"@ljharb/eslint-config": "^22.2.2",
|
|
40
40
|
"browserify": "^16.5.2",
|
|
41
41
|
"bundle-collapser": "^1.4.0",
|
|
42
42
|
"common-shakeify": "~1.0.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"has-property-descriptors": "^1.0.2",
|
|
52
52
|
"has-proto": "^1.2.0",
|
|
53
53
|
"has-symbols": "^1.1.0",
|
|
54
|
-
"iconv-lite": "^0.5.
|
|
54
|
+
"iconv-lite": "^0.5.2",
|
|
55
55
|
"in-publish": "^2.0.1",
|
|
56
56
|
"jackspeak": "=2.1.1",
|
|
57
57
|
"jiti": "^0.0.0",
|
package/test/parse.js
CHANGED
|
@@ -213,6 +213,18 @@ test('parse()', function (t) {
|
|
|
213
213
|
st.end();
|
|
214
214
|
});
|
|
215
215
|
|
|
216
|
+
t.test('ignores prototype keys when depth = 0 and allowPrototypes is false', function (st) {
|
|
217
|
+
st.deepEqual(qs.parse('toString=foo', { depth: 0 }), {});
|
|
218
|
+
st.deepEqual(qs.parse('hasOwnProperty=bar', { depth: 0 }), {});
|
|
219
|
+
st.deepEqual(qs.parse('toString=foo&a=b', { depth: 0 }), { a: 'b' });
|
|
220
|
+
st.end();
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
t.test('allows prototype keys when depth = 0 and allowPrototypes is true', function (st) {
|
|
224
|
+
st.deepEqual(qs.parse('toString=foo', { depth: 0, allowPrototypes: true }), { toString: 'foo' });
|
|
225
|
+
st.end();
|
|
226
|
+
});
|
|
227
|
+
|
|
216
228
|
t.test('uses original key when depth = false', function (st) {
|
|
217
229
|
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { depth: false }), { 'a[0]': 'b', 'a[1]': 'c' });
|
|
218
230
|
st.deepEqual(qs.parse('a[0][0]=b&a[0][1]=c&a[1]=d&e=2', { depth: false }), { 'a[0][0]': 'b', 'a[0][1]': 'c', 'a[1]': 'd', e: '2' });
|
|
@@ -784,25 +796,25 @@ test('parse()', function (t) {
|
|
|
784
796
|
|
|
785
797
|
t.test('add keys to objects', function (st) {
|
|
786
798
|
st.deepEqual(
|
|
787
|
-
qs.parse('a[b]=c&a=d'),
|
|
799
|
+
qs.parse('a[b]=c&a=d', { strictMerge: false }),
|
|
788
800
|
{ a: { b: 'c', d: true } },
|
|
789
801
|
'can add keys to objects'
|
|
790
802
|
);
|
|
791
803
|
|
|
792
804
|
st.deepEqual(
|
|
793
|
-
qs.parse('a[b]=c&a=toString'),
|
|
805
|
+
qs.parse('a[b]=c&a=toString', { strictMerge: false }),
|
|
794
806
|
{ a: { b: 'c' } },
|
|
795
807
|
'can not overwrite prototype'
|
|
796
808
|
);
|
|
797
809
|
|
|
798
810
|
st.deepEqual(
|
|
799
|
-
qs.parse('a[b]=c&a=toString', { allowPrototypes: true }),
|
|
811
|
+
qs.parse('a[b]=c&a=toString', { strictMerge: false, allowPrototypes: true }),
|
|
800
812
|
{ a: { b: 'c', toString: true } },
|
|
801
813
|
'can overwrite prototype with allowPrototypes true'
|
|
802
814
|
);
|
|
803
815
|
|
|
804
816
|
st.deepEqual(
|
|
805
|
-
qs.parse('a[b]=c&a=toString', { plainObjects: true }),
|
|
817
|
+
qs.parse('a[b]=c&a=toString', { strictMerge: false, plainObjects: true }),
|
|
806
818
|
{ __proto__: null, a: { __proto__: null, b: 'c', toString: true } },
|
|
807
819
|
'can overwrite prototype with plainObjects true'
|
|
808
820
|
);
|
|
@@ -810,6 +822,34 @@ test('parse()', function (t) {
|
|
|
810
822
|
st.end();
|
|
811
823
|
});
|
|
812
824
|
|
|
825
|
+
t.test('strictMerge wraps object and primitive into an array', function (st) {
|
|
826
|
+
st.deepEqual(
|
|
827
|
+
qs.parse('a[b]=c&a=d'),
|
|
828
|
+
{ a: [{ b: 'c' }, 'd'] },
|
|
829
|
+
'object then primitive produces array'
|
|
830
|
+
);
|
|
831
|
+
|
|
832
|
+
st.deepEqual(
|
|
833
|
+
qs.parse('a=d&a[b]=c'),
|
|
834
|
+
{ a: ['d', { b: 'c' }] },
|
|
835
|
+
'primitive then object produces array'
|
|
836
|
+
);
|
|
837
|
+
|
|
838
|
+
st.deepEqual(
|
|
839
|
+
qs.parse('a[b]=c&a=toString'),
|
|
840
|
+
{ a: [{ b: 'c' }, 'toString'] },
|
|
841
|
+
'prototype-colliding value is preserved in array'
|
|
842
|
+
);
|
|
843
|
+
|
|
844
|
+
st.deepEqual(
|
|
845
|
+
qs.parse('a[b]=c&a=toString', { plainObjects: true }),
|
|
846
|
+
{ __proto__: null, a: [{ __proto__: null, b: 'c' }, 'toString'] },
|
|
847
|
+
'plainObjects preserved in array wrapping'
|
|
848
|
+
);
|
|
849
|
+
|
|
850
|
+
st.end();
|
|
851
|
+
});
|
|
852
|
+
|
|
813
853
|
t.test('dunder proto is ignored', function (st) {
|
|
814
854
|
var payload = 'categories[__proto__]=login&categories[__proto__]&categories[length]=42';
|
|
815
855
|
var result = qs.parse(payload, { allowPrototypes: true });
|
|
@@ -1046,6 +1086,15 @@ test('parse()', function (t) {
|
|
|
1046
1086
|
};
|
|
1047
1087
|
|
|
1048
1088
|
st.deepEqual(qs.parse('KeY=vAlUe', { decoder: decoder }), { key: 'VALUE' });
|
|
1089
|
+
|
|
1090
|
+
var noopDecoder = function () { return 'x'; };
|
|
1091
|
+
noopDecoder();
|
|
1092
|
+
st['throws'](
|
|
1093
|
+
function () { decoder('x', noopDecoder, 'utf-8', 'unknown'); },
|
|
1094
|
+
'this should never happen! type: unknown',
|
|
1095
|
+
'decoder throws for unexpected type'
|
|
1096
|
+
);
|
|
1097
|
+
|
|
1049
1098
|
st.end();
|
|
1050
1099
|
});
|
|
1051
1100
|
|
|
@@ -1075,6 +1124,14 @@ test('parse()', function (t) {
|
|
|
1075
1124
|
new RangeError('Parameter limit exceeded. Only 3 parameters allowed.'),
|
|
1076
1125
|
'throws error when parameter limit is exceeded'
|
|
1077
1126
|
);
|
|
1127
|
+
|
|
1128
|
+
sst['throws'](
|
|
1129
|
+
function () {
|
|
1130
|
+
qs.parse('a=1&b=2', { parameterLimit: 1, throwOnLimitExceeded: true });
|
|
1131
|
+
},
|
|
1132
|
+
new RangeError('Parameter limit exceeded. Only 1 parameter allowed.'),
|
|
1133
|
+
'throws error with singular "parameter" when parameterLimit is 1'
|
|
1134
|
+
);
|
|
1078
1135
|
sst.end();
|
|
1079
1136
|
});
|
|
1080
1137
|
|
|
@@ -1096,6 +1153,12 @@ test('parse()', function (t) {
|
|
|
1096
1153
|
sst.end();
|
|
1097
1154
|
});
|
|
1098
1155
|
|
|
1156
|
+
st.test('allows unlimited parameters when parameterLimit is Infinity and throwOnLimitExceeded is true', function (sst) {
|
|
1157
|
+
var result = qs.parse('a=1&b=2&c=3&d=4&e=5&f=6', { parameterLimit: Infinity, throwOnLimitExceeded: true });
|
|
1158
|
+
sst.deepEqual(result, { a: '1', b: '2', c: '3', d: '4', e: '5', f: '6' }, 'parses all parameters without truncation or throwing');
|
|
1159
|
+
sst.end();
|
|
1160
|
+
});
|
|
1161
|
+
|
|
1099
1162
|
st.end();
|
|
1100
1163
|
});
|
|
1101
1164
|
|
|
@@ -1161,6 +1224,14 @@ test('parse()', function (t) {
|
|
|
1161
1224
|
'throws error when a sparse index exceeds arrayLimit'
|
|
1162
1225
|
);
|
|
1163
1226
|
|
|
1227
|
+
sst['throws'](
|
|
1228
|
+
function () {
|
|
1229
|
+
qs.parse('a[2]=b', { arrayLimit: 1, throwOnLimitExceeded: true });
|
|
1230
|
+
},
|
|
1231
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
1232
|
+
'throws error with singular "element" when arrayLimit is 1'
|
|
1233
|
+
);
|
|
1234
|
+
|
|
1164
1235
|
sst.end();
|
|
1165
1236
|
});
|
|
1166
1237
|
|
|
@@ -1178,6 +1249,17 @@ test('parse()', function (t) {
|
|
|
1178
1249
|
sst.end();
|
|
1179
1250
|
});
|
|
1180
1251
|
|
|
1252
|
+
st.test('throws when duplicate bracket keys exceed arrayLimit with throwOnLimitExceeded', function (sst) {
|
|
1253
|
+
sst['throws'](
|
|
1254
|
+
function () {
|
|
1255
|
+
qs.parse('a[]=1&a[]=2&a[]=3&a[]=4&a[]=5&a[]=6', { arrayLimit: 5, throwOnLimitExceeded: true });
|
|
1256
|
+
},
|
|
1257
|
+
new RangeError('Array limit exceeded. Only 5 elements allowed in an array.'),
|
|
1258
|
+
'throws error when duplicate bracket notation exceeds array limit'
|
|
1259
|
+
);
|
|
1260
|
+
sst.end();
|
|
1261
|
+
});
|
|
1262
|
+
|
|
1181
1263
|
st.end();
|
|
1182
1264
|
});
|
|
1183
1265
|
|
|
@@ -1229,6 +1311,34 @@ test('`duplicates` option', function (t) {
|
|
|
1229
1311
|
'duplicates: last'
|
|
1230
1312
|
);
|
|
1231
1313
|
|
|
1314
|
+
t.test('bracket notation always combines regardless of duplicates', function (st) {
|
|
1315
|
+
st.deepEqual(
|
|
1316
|
+
qs.parse('a=1&a=2&b[]=1&b[]=2', { duplicates: 'last' }),
|
|
1317
|
+
{ a: '2', b: ['1', '2'] },
|
|
1318
|
+
'duplicates last: unbracketed takes last, bracketed combines'
|
|
1319
|
+
);
|
|
1320
|
+
|
|
1321
|
+
st.deepEqual(
|
|
1322
|
+
qs.parse('b[]=1&b[]=2', { duplicates: 'last' }),
|
|
1323
|
+
{ b: ['1', '2'] },
|
|
1324
|
+
'duplicates last: bracketed always combines'
|
|
1325
|
+
);
|
|
1326
|
+
|
|
1327
|
+
st.deepEqual(
|
|
1328
|
+
qs.parse('b[]=1&b[]=2', { duplicates: 'first' }),
|
|
1329
|
+
{ b: ['1', '2'] },
|
|
1330
|
+
'duplicates first: bracketed always combines'
|
|
1331
|
+
);
|
|
1332
|
+
|
|
1333
|
+
st.deepEqual(
|
|
1334
|
+
qs.parse('a=1&a=2&b[]=1&b[]=2', { duplicates: 'first' }),
|
|
1335
|
+
{ a: '1', b: ['1', '2'] },
|
|
1336
|
+
'duplicates first: unbracketed takes first, bracketed combines'
|
|
1337
|
+
);
|
|
1338
|
+
|
|
1339
|
+
st.end();
|
|
1340
|
+
});
|
|
1341
|
+
|
|
1232
1342
|
t.end();
|
|
1233
1343
|
});
|
|
1234
1344
|
|
|
@@ -1406,6 +1516,14 @@ test('comma + arrayLimit', function (t) {
|
|
|
1406
1516
|
new RangeError('Array limit exceeded. Only 3 elements allowed in an array.'),
|
|
1407
1517
|
'throws error when comma-split exceeds array limit'
|
|
1408
1518
|
);
|
|
1519
|
+
|
|
1520
|
+
st['throws'](
|
|
1521
|
+
function () {
|
|
1522
|
+
qs.parse('a=1,2,3', { comma: true, arrayLimit: 1, throwOnLimitExceeded: true });
|
|
1523
|
+
},
|
|
1524
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
1525
|
+
'throws error with singular "element" when arrayLimit is 1'
|
|
1526
|
+
);
|
|
1409
1527
|
st.end();
|
|
1410
1528
|
});
|
|
1411
1529
|
|
|
@@ -1508,5 +1626,29 @@ test('mixed array and object notation', function (t) {
|
|
|
1508
1626
|
st.end();
|
|
1509
1627
|
});
|
|
1510
1628
|
|
|
1629
|
+
t.test('uses existing array length for currentArrayLength when parsing object input with bracket keys', function (st) {
|
|
1630
|
+
var input = {};
|
|
1631
|
+
var arr = ['x', 'y'];
|
|
1632
|
+
arr.a = ['z', 'w'];
|
|
1633
|
+
input['a[]'] = arr;
|
|
1634
|
+
st.deepEqual(qs.parse(input), { a: ['x', 'y'] }, 'parses object input with bracket keys using existing array values');
|
|
1635
|
+
st.end();
|
|
1636
|
+
});
|
|
1637
|
+
|
|
1638
|
+
t.test('throws with singular message when object input bracket key exceeds arrayLimit of 1', function (st) {
|
|
1639
|
+
var input = {};
|
|
1640
|
+
var arr = ['x'];
|
|
1641
|
+
arr.a = ['z', 'w'];
|
|
1642
|
+
input['a[]'] = arr;
|
|
1643
|
+
st['throws'](
|
|
1644
|
+
function () {
|
|
1645
|
+
qs.parse(input, { throwOnLimitExceeded: true, arrayLimit: 1 });
|
|
1646
|
+
},
|
|
1647
|
+
new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
|
|
1648
|
+
'throws singular error for object input exceeding arrayLimit 1'
|
|
1649
|
+
);
|
|
1650
|
+
st.end();
|
|
1651
|
+
});
|
|
1652
|
+
|
|
1511
1653
|
t.end();
|
|
1512
1654
|
});
|
package/test/stringify.js
CHANGED
|
@@ -1188,6 +1188,15 @@ test('stringify()', function (t) {
|
|
|
1188
1188
|
};
|
|
1189
1189
|
|
|
1190
1190
|
st.deepEqual(qs.stringify({ KeY: 'vAlUe' }, { encoder: encoder }), 'key=VALUE');
|
|
1191
|
+
|
|
1192
|
+
var noopEncoder = function () { return 'x'; };
|
|
1193
|
+
noopEncoder();
|
|
1194
|
+
st['throws'](
|
|
1195
|
+
function () { encoder('x', noopEncoder, 'utf-8', 'unknown'); },
|
|
1196
|
+
'this should never happen! type: unknown',
|
|
1197
|
+
'encoder throws for unexpected type'
|
|
1198
|
+
);
|
|
1199
|
+
|
|
1191
1200
|
st.end();
|
|
1192
1201
|
});
|
|
1193
1202
|
|
package/test/utils.js
CHANGED
|
@@ -31,6 +31,7 @@ test('merge()', function (t) {
|
|
|
31
31
|
t.deepEqual(noOptionsNonObjectSource, { foo: 'baz', bar: true });
|
|
32
32
|
|
|
33
33
|
var func = function f() {};
|
|
34
|
+
func();
|
|
34
35
|
t.deepEqual(
|
|
35
36
|
utils.merge(func, { foo: 'bar' }),
|
|
36
37
|
[func, { foo: 'bar' }],
|
|
@@ -95,6 +96,13 @@ test('merge()', function (t) {
|
|
|
95
96
|
s2t.end();
|
|
96
97
|
});
|
|
97
98
|
|
|
99
|
+
st.test('with strictMerge, wraps object and primitive in array', function (s2t) {
|
|
100
|
+
var obj = { foo: 'bar' };
|
|
101
|
+
var merged = utils.merge(obj, 'baz', { strictMerge: true });
|
|
102
|
+
s2t.deepEqual(merged, [{ foo: 'bar' }, 'baz'], 'wraps in array with strictMerge');
|
|
103
|
+
s2t.end();
|
|
104
|
+
});
|
|
105
|
+
|
|
98
106
|
st.test('merges overflow object into primitive', function (s2t) {
|
|
99
107
|
// Create an overflow object via combine: 2 elements (indices 0-1) with limit 0
|
|
100
108
|
var overflow = utils.combine(['a'], 'b', 0, false);
|
|
@@ -105,6 +113,15 @@ test('merge()', function (t) {
|
|
|
105
113
|
s2t.end();
|
|
106
114
|
});
|
|
107
115
|
|
|
116
|
+
st.test('merges overflow object into primitive with plainObjects', function (s2t) {
|
|
117
|
+
var overflow = utils.combine(['a'], 'b', 0, false);
|
|
118
|
+
s2t.ok(utils.isOverflow(overflow), 'overflow object is marked');
|
|
119
|
+
var merged = utils.merge('c', overflow, { plainObjects: true });
|
|
120
|
+
s2t.ok(utils.isOverflow(merged), 'result is also marked as overflow');
|
|
121
|
+
s2t.deepEqual(merged, { __proto__: null, 0: 'c', 1: 'a', 2: 'b' }, 'creates null-proto object with primitive at 0');
|
|
122
|
+
s2t.end();
|
|
123
|
+
});
|
|
124
|
+
|
|
108
125
|
st.test('merges overflow object with multiple values into primitive', function (s2t) {
|
|
109
126
|
// Create an overflow object via combine: 3 elements (indices 0-2) with limit 0
|
|
110
127
|
var overflow = utils.combine(['b', 'c'], 'd', 0, false);
|
|
@@ -121,6 +138,21 @@ test('merge()', function (t) {
|
|
|
121
138
|
s2t.end();
|
|
122
139
|
});
|
|
123
140
|
|
|
141
|
+
st.test('merges primitive into array that exceeds arrayLimit', function (s2t) {
|
|
142
|
+
var arr = ['a', 'b', 'c'];
|
|
143
|
+
var merged = utils.merge(arr, 'd', { arrayLimit: 1 });
|
|
144
|
+
s2t.ok(utils.isOverflow(merged), 'result is marked as overflow');
|
|
145
|
+
s2t.deepEqual(merged, { 0: 'a', 1: 'b', 2: 'c', 3: 'd' }, 'converts to overflow object with primitive appended');
|
|
146
|
+
s2t.end();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
st.test('merges array into primitive that exceeds arrayLimit', function (s2t) {
|
|
150
|
+
var merged = utils.merge('a', ['b', 'c'], { arrayLimit: 1 });
|
|
151
|
+
s2t.ok(utils.isOverflow(merged), 'result is marked as overflow');
|
|
152
|
+
s2t.deepEqual(merged, { 0: 'a', 1: 'b', 2: 'c' }, 'converts to overflow object');
|
|
153
|
+
s2t.end();
|
|
154
|
+
});
|
|
155
|
+
|
|
124
156
|
st.end();
|
|
125
157
|
});
|
|
126
158
|
|
|
@@ -369,7 +401,9 @@ test('encode', function (t) {
|
|
|
369
401
|
});
|
|
370
402
|
|
|
371
403
|
test('isBuffer()', function (t) {
|
|
372
|
-
|
|
404
|
+
var fn = function () {};
|
|
405
|
+
fn();
|
|
406
|
+
forEach([null, undefined, true, false, '', 'abc', 42, 0, NaN, {}, [], fn, /a/g], function (x) {
|
|
373
407
|
t.equal(utils.isBuffer(x), false, inspect(x) + ' is not a buffer');
|
|
374
408
|
});
|
|
375
409
|
|
|
@@ -379,8 +413,9 @@ test('isBuffer()', function (t) {
|
|
|
379
413
|
var saferBuffer = SaferBuffer.from('abc');
|
|
380
414
|
t.equal(utils.isBuffer(saferBuffer), true, 'SaferBuffer instance is a buffer');
|
|
381
415
|
|
|
382
|
-
var buffer =
|
|
383
|
-
t.
|
|
416
|
+
var buffer = SaferBuffer.from('abc');
|
|
417
|
+
t.notEqual(saferBuffer, buffer, 'different buffer instances');
|
|
418
|
+
t.equal(utils.isBuffer(buffer), true, 'another Buffer instance is a buffer');
|
|
384
419
|
t.end();
|
|
385
420
|
});
|
|
386
421
|
|