qs 5.2.0 → 5.2.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 +102 -97
- package/dist/qs.js +25 -18
- package/lib/parse.js +10 -15
- package/package.json +1 -1
- package/test/parse.js +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,99 +1,104 @@
|
|
|
1
|
+
## **5.2.1**
|
|
2
|
+
- [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values
|
|
1
3
|
|
|
2
|
-
## [**5.
|
|
3
|
-
- [**#
|
|
4
|
-
|
|
4
|
+
## [**5.2.0**](https://github.com/ljharb/qs/issues?milestone=30&state=closed)
|
|
5
|
+
- [**#64**](https://github.com/ljharb/qs/issues/64) Add option to sort object keys in the query string
|
|
6
|
+
|
|
7
|
+
## [**5.1.0**](https://github.com/ljharb/qs/issues?milestone=29&state=closed)
|
|
8
|
+
- [**#117**](https://github.com/ljharb/qs/issues/117) make URI encoding stringified results optional
|
|
9
|
+
- [**#106**](https://github.com/ljharb/qs/issues/106) Add flag `skipNulls` to optionally skip null values in stringify
|
|
10
|
+
|
|
11
|
+
## [**5.0.0**](https://github.com/ljharb/qs/issues?milestone=28&state=closed)
|
|
12
|
+
- [**#114**](https://github.com/ljharb/qs/issues/114) default allowDots to false
|
|
13
|
+
- [**#100**](https://github.com/ljharb/qs/issues/100) include dist to npm
|
|
14
|
+
|
|
15
|
+
## [**4.0.0**](https://github.com/ljharb/qs/issues?milestone=26&state=closed)
|
|
16
|
+
- [**#98**](https://github.com/ljharb/qs/issues/98) make returning plain objects and allowing prototype overwriting properties optional
|
|
17
|
+
|
|
18
|
+
## [**3.1.0**](https://github.com/ljharb/qs/issues?milestone=24&state=closed)
|
|
19
|
+
- [**#89**](https://github.com/ljharb/qs/issues/89) Add option to disable "Transform dot notation to bracket notation"
|
|
20
|
+
|
|
21
|
+
## [**3.0.0**](https://github.com/ljharb/qs/issues?milestone=23&state=closed)
|
|
22
|
+
- [**#80**](https://github.com/ljharb/qs/issues/80) qs.parse silently drops properties
|
|
23
|
+
- [**#77**](https://github.com/ljharb/qs/issues/77) Perf boost
|
|
24
|
+
- [**#60**](https://github.com/ljharb/qs/issues/60) Add explicit option to disable array parsing
|
|
25
|
+
- [**#74**](https://github.com/ljharb/qs/issues/74) Bad parse when turning array into object
|
|
26
|
+
- [**#81**](https://github.com/ljharb/qs/issues/81) Add a `filter` option
|
|
27
|
+
- [**#68**](https://github.com/ljharb/qs/issues/68) Fixed issue with recursion and passing strings into objects.
|
|
28
|
+
- [**#66**](https://github.com/ljharb/qs/issues/66) Add mixed array and object dot notation support Closes: #47
|
|
29
|
+
- [**#76**](https://github.com/ljharb/qs/issues/76) RFC 3986
|
|
30
|
+
- [**#85**](https://github.com/ljharb/qs/issues/85) No equal sign
|
|
31
|
+
- [**#84**](https://github.com/ljharb/qs/issues/84) update license attribute
|
|
32
|
+
|
|
33
|
+
## [**2.4.1**](https://github.com/ljharb/qs/issues?milestone=20&state=closed)
|
|
34
|
+
- [**#73**](https://github.com/ljharb/qs/issues/73) Property 'hasOwnProperty' of object #<Object> is not a function
|
|
35
|
+
|
|
36
|
+
## [**2.4.0**](https://github.com/ljharb/qs/issues?milestone=19&state=closed)
|
|
37
|
+
- [**#70**](https://github.com/ljharb/qs/issues/70) Add arrayFormat option
|
|
38
|
+
|
|
39
|
+
## [**2.3.3**](https://github.com/ljharb/qs/issues?milestone=18&state=closed)
|
|
40
|
+
- [**#59**](https://github.com/ljharb/qs/issues/59) make sure array indexes are >= 0, closes #57
|
|
41
|
+
- [**#58**](https://github.com/ljharb/qs/issues/58) make qs usable for browser loader
|
|
42
|
+
|
|
43
|
+
## [**2.3.2**](https://github.com/ljharb/qs/issues?milestone=17&state=closed)
|
|
44
|
+
- [**#55**](https://github.com/ljharb/qs/issues/55) allow merging a string into an object
|
|
45
|
+
|
|
46
|
+
## [**2.3.1**](https://github.com/ljharb/qs/issues?milestone=16&state=closed)
|
|
47
|
+
- [**#52**](https://github.com/ljharb/qs/issues/52) Return "undefined" and "false" instead of throwing "TypeError".
|
|
48
|
+
|
|
49
|
+
## [**2.3.0**](https://github.com/ljharb/qs/issues?milestone=15&state=closed)
|
|
50
|
+
- [**#50**](https://github.com/ljharb/qs/issues/50) add option to omit array indices, closes #46
|
|
51
|
+
|
|
52
|
+
## [**2.2.5**](https://github.com/ljharb/qs/issues?milestone=14&state=closed)
|
|
53
|
+
- [**#39**](https://github.com/ljharb/qs/issues/39) Is there an alternative to Buffer.isBuffer?
|
|
54
|
+
- [**#49**](https://github.com/ljharb/qs/issues/49) refactor utils.merge, fixes #45
|
|
55
|
+
- [**#41**](https://github.com/ljharb/qs/issues/41) avoid browserifying Buffer, for #39
|
|
56
|
+
|
|
57
|
+
## [**2.2.4**](https://github.com/ljharb/qs/issues?milestone=13&state=closed)
|
|
58
|
+
- [**#38**](https://github.com/ljharb/qs/issues/38) how to handle object keys beginning with a number
|
|
59
|
+
|
|
60
|
+
## [**2.2.3**](https://github.com/ljharb/qs/issues?milestone=12&state=closed)
|
|
61
|
+
- [**#37**](https://github.com/ljharb/qs/issues/37) parser discards first empty value in array
|
|
62
|
+
- [**#36**](https://github.com/ljharb/qs/issues/36) Update to lab 4.x
|
|
63
|
+
|
|
64
|
+
## [**2.2.2**](https://github.com/ljharb/qs/issues?milestone=11&state=closed)
|
|
65
|
+
- [**#33**](https://github.com/ljharb/qs/issues/33) Error when plain object in a value
|
|
66
|
+
- [**#34**](https://github.com/ljharb/qs/issues/34) use Object.prototype.hasOwnProperty.call instead of obj.hasOwnProperty
|
|
67
|
+
- [**#24**](https://github.com/ljharb/qs/issues/24) Changelog? Semver?
|
|
68
|
+
|
|
69
|
+
## [**2.2.1**](https://github.com/ljharb/qs/issues?milestone=10&state=closed)
|
|
70
|
+
- [**#32**](https://github.com/ljharb/qs/issues/32) account for circular references properly, closes #31
|
|
71
|
+
- [**#31**](https://github.com/ljharb/qs/issues/31) qs.parse stackoverflow on circular objects
|
|
72
|
+
|
|
73
|
+
## [**2.2.0**](https://github.com/ljharb/qs/issues?milestone=9&state=closed)
|
|
74
|
+
- [**#26**](https://github.com/ljharb/qs/issues/26) Don't use Buffer global if it's not present
|
|
75
|
+
- [**#30**](https://github.com/ljharb/qs/issues/30) Bug when merging non-object values into arrays
|
|
76
|
+
- [**#29**](https://github.com/ljharb/qs/issues/29) Don't call Utils.clone at the top of Utils.merge
|
|
77
|
+
- [**#23**](https://github.com/ljharb/qs/issues/23) Ability to not limit parameters?
|
|
78
|
+
|
|
79
|
+
## [**2.1.0**](https://github.com/ljharb/qs/issues?milestone=8&state=closed)
|
|
80
|
+
- [**#22**](https://github.com/ljharb/qs/issues/22) Enable using a RegExp as delimiter
|
|
81
|
+
|
|
82
|
+
## [**2.0.0**](https://github.com/ljharb/qs/issues?milestone=7&state=closed)
|
|
83
|
+
- [**#18**](https://github.com/ljharb/qs/issues/18) Why is there arrayLimit?
|
|
84
|
+
- [**#20**](https://github.com/ljharb/qs/issues/20) Configurable parametersLimit
|
|
85
|
+
- [**#21**](https://github.com/ljharb/qs/issues/21) make all limits optional, for #18, for #20
|
|
86
|
+
|
|
87
|
+
## [**1.2.2**](https://github.com/ljharb/qs/issues?milestone=6&state=closed)
|
|
88
|
+
- [**#19**](https://github.com/ljharb/qs/issues/19) Don't overwrite null values
|
|
89
|
+
|
|
90
|
+
## [**1.2.1**](https://github.com/ljharb/qs/issues?milestone=5&state=closed)
|
|
91
|
+
- [**#16**](https://github.com/ljharb/qs/issues/16) ignore non-string delimiters
|
|
92
|
+
- [**#15**](https://github.com/ljharb/qs/issues/15) Close code block
|
|
93
|
+
|
|
94
|
+
## [**1.2.0**](https://github.com/ljharb/qs/issues?milestone=4&state=closed)
|
|
95
|
+
- [**#12**](https://github.com/ljharb/qs/issues/12) Add optional delim argument
|
|
96
|
+
- [**#13**](https://github.com/ljharb/qs/issues/13) fix #11: flattened keys in array are now correctly parsed
|
|
97
|
+
|
|
98
|
+
## [**1.1.0**](https://github.com/ljharb/qs/issues?milestone=3&state=closed)
|
|
99
|
+
- [**#7**](https://github.com/ljharb/qs/issues/7) Empty values of a POST array disappear after being submitted
|
|
100
|
+
- [**#9**](https://github.com/ljharb/qs/issues/9) Should not omit equals signs (=) when value is null
|
|
101
|
+
- [**#6**](https://github.com/ljharb/qs/issues/6) Minor grammar fix in README
|
|
5
102
|
|
|
6
|
-
## [**
|
|
7
|
-
- [**#
|
|
8
|
-
- [**#100**](https://github.com/hapijs/qs/issues/100) include dist to npm
|
|
9
|
-
|
|
10
|
-
## [**4.0.0**](https://github.com/hapijs/qs/issues?milestone=26&state=closed)
|
|
11
|
-
- [**#98**](https://github.com/hapijs/qs/issues/98) make returning plain objects and allowing prototype overwriting properties optional
|
|
12
|
-
|
|
13
|
-
## [**3.1.0**](https://github.com/hapijs/qs/issues?milestone=24&state=closed)
|
|
14
|
-
- [**#89**](https://github.com/hapijs/qs/issues/89) Add option to disable "Transform dot notation to bracket notation"
|
|
15
|
-
|
|
16
|
-
## [**3.0.0**](https://github.com/hapijs/qs/issues?milestone=23&state=closed)
|
|
17
|
-
- [**#80**](https://github.com/hapijs/qs/issues/80) qs.parse silently drops properties
|
|
18
|
-
- [**#77**](https://github.com/hapijs/qs/issues/77) Perf boost
|
|
19
|
-
- [**#60**](https://github.com/hapijs/qs/issues/60) Add explicit option to disable array parsing
|
|
20
|
-
- [**#74**](https://github.com/hapijs/qs/issues/74) Bad parse when turning array into object
|
|
21
|
-
- [**#81**](https://github.com/hapijs/qs/issues/81) Add a `filter` option
|
|
22
|
-
- [**#68**](https://github.com/hapijs/qs/issues/68) Fixed issue with recursion and passing strings into objects.
|
|
23
|
-
- [**#66**](https://github.com/hapijs/qs/issues/66) Add mixed array and object dot notation support Closes: #47
|
|
24
|
-
- [**#76**](https://github.com/hapijs/qs/issues/76) RFC 3986
|
|
25
|
-
- [**#85**](https://github.com/hapijs/qs/issues/85) No equal sign
|
|
26
|
-
- [**#84**](https://github.com/hapijs/qs/issues/84) update license attribute
|
|
27
|
-
|
|
28
|
-
## [**2.4.1**](https://github.com/hapijs/qs/issues?milestone=20&state=closed)
|
|
29
|
-
- [**#73**](https://github.com/hapijs/qs/issues/73) Property 'hasOwnProperty' of object #<Object> is not a function
|
|
30
|
-
|
|
31
|
-
## [**2.4.0**](https://github.com/hapijs/qs/issues?milestone=19&state=closed)
|
|
32
|
-
- [**#70**](https://github.com/hapijs/qs/issues/70) Add arrayFormat option
|
|
33
|
-
|
|
34
|
-
## [**2.3.3**](https://github.com/hapijs/qs/issues?milestone=18&state=closed)
|
|
35
|
-
- [**#59**](https://github.com/hapijs/qs/issues/59) make sure array indexes are >= 0, closes #57
|
|
36
|
-
- [**#58**](https://github.com/hapijs/qs/issues/58) make qs usable for browser loader
|
|
37
|
-
|
|
38
|
-
## [**2.3.2**](https://github.com/hapijs/qs/issues?milestone=17&state=closed)
|
|
39
|
-
- [**#55**](https://github.com/hapijs/qs/issues/55) allow merging a string into an object
|
|
40
|
-
|
|
41
|
-
## [**2.3.1**](https://github.com/hapijs/qs/issues?milestone=16&state=closed)
|
|
42
|
-
- [**#52**](https://github.com/hapijs/qs/issues/52) Return "undefined" and "false" instead of throwing "TypeError".
|
|
43
|
-
|
|
44
|
-
## [**2.3.0**](https://github.com/hapijs/qs/issues?milestone=15&state=closed)
|
|
45
|
-
- [**#50**](https://github.com/hapijs/qs/issues/50) add option to omit array indices, closes #46
|
|
46
|
-
|
|
47
|
-
## [**2.2.5**](https://github.com/hapijs/qs/issues?milestone=14&state=closed)
|
|
48
|
-
- [**#39**](https://github.com/hapijs/qs/issues/39) Is there an alternative to Buffer.isBuffer?
|
|
49
|
-
- [**#49**](https://github.com/hapijs/qs/issues/49) refactor utils.merge, fixes #45
|
|
50
|
-
- [**#41**](https://github.com/hapijs/qs/issues/41) avoid browserifying Buffer, for #39
|
|
51
|
-
|
|
52
|
-
## [**2.2.4**](https://github.com/hapijs/qs/issues?milestone=13&state=closed)
|
|
53
|
-
- [**#38**](https://github.com/hapijs/qs/issues/38) how to handle object keys beginning with a number
|
|
54
|
-
|
|
55
|
-
## [**2.2.3**](https://github.com/hapijs/qs/issues?milestone=12&state=closed)
|
|
56
|
-
- [**#37**](https://github.com/hapijs/qs/issues/37) parser discards first empty value in array
|
|
57
|
-
- [**#36**](https://github.com/hapijs/qs/issues/36) Update to lab 4.x
|
|
58
|
-
|
|
59
|
-
## [**2.2.2**](https://github.com/hapijs/qs/issues?milestone=11&state=closed)
|
|
60
|
-
- [**#33**](https://github.com/hapijs/qs/issues/33) Error when plain object in a value
|
|
61
|
-
- [**#34**](https://github.com/hapijs/qs/issues/34) use Object.prototype.hasOwnProperty.call instead of obj.hasOwnProperty
|
|
62
|
-
- [**#24**](https://github.com/hapijs/qs/issues/24) Changelog? Semver?
|
|
63
|
-
|
|
64
|
-
## [**2.2.1**](https://github.com/hapijs/qs/issues?milestone=10&state=closed)
|
|
65
|
-
- [**#32**](https://github.com/hapijs/qs/issues/32) account for circular references properly, closes #31
|
|
66
|
-
- [**#31**](https://github.com/hapijs/qs/issues/31) qs.parse stackoverflow on circular objects
|
|
67
|
-
|
|
68
|
-
## [**2.2.0**](https://github.com/hapijs/qs/issues?milestone=9&state=closed)
|
|
69
|
-
- [**#26**](https://github.com/hapijs/qs/issues/26) Don't use Buffer global if it's not present
|
|
70
|
-
- [**#30**](https://github.com/hapijs/qs/issues/30) Bug when merging non-object values into arrays
|
|
71
|
-
- [**#29**](https://github.com/hapijs/qs/issues/29) Don't call Utils.clone at the top of Utils.merge
|
|
72
|
-
- [**#23**](https://github.com/hapijs/qs/issues/23) Ability to not limit parameters?
|
|
73
|
-
|
|
74
|
-
## [**2.1.0**](https://github.com/hapijs/qs/issues?milestone=8&state=closed)
|
|
75
|
-
- [**#22**](https://github.com/hapijs/qs/issues/22) Enable using a RegExp as delimiter
|
|
76
|
-
|
|
77
|
-
## [**2.0.0**](https://github.com/hapijs/qs/issues?milestone=7&state=closed)
|
|
78
|
-
- [**#18**](https://github.com/hapijs/qs/issues/18) Why is there arrayLimit?
|
|
79
|
-
- [**#20**](https://github.com/hapijs/qs/issues/20) Configurable parametersLimit
|
|
80
|
-
- [**#21**](https://github.com/hapijs/qs/issues/21) make all limits optional, for #18, for #20
|
|
81
|
-
|
|
82
|
-
## [**1.2.2**](https://github.com/hapijs/qs/issues?milestone=6&state=closed)
|
|
83
|
-
- [**#19**](https://github.com/hapijs/qs/issues/19) Don't overwrite null values
|
|
84
|
-
|
|
85
|
-
## [**1.2.1**](https://github.com/hapijs/qs/issues?milestone=5&state=closed)
|
|
86
|
-
- [**#16**](https://github.com/hapijs/qs/issues/16) ignore non-string delimiters
|
|
87
|
-
- [**#15**](https://github.com/hapijs/qs/issues/15) Close code block
|
|
88
|
-
|
|
89
|
-
## [**1.2.0**](https://github.com/hapijs/qs/issues?milestone=4&state=closed)
|
|
90
|
-
- [**#12**](https://github.com/hapijs/qs/issues/12) Add optional delim argument
|
|
91
|
-
- [**#13**](https://github.com/hapijs/qs/issues/13) fix #11: flattened keys in array are now correctly parsed
|
|
92
|
-
|
|
93
|
-
## [**1.1.0**](https://github.com/hapijs/qs/issues?milestone=3&state=closed)
|
|
94
|
-
- [**#7**](https://github.com/hapijs/qs/issues/7) Empty values of a POST array disappear after being submitted
|
|
95
|
-
- [**#9**](https://github.com/hapijs/qs/issues/9) Should not omit equals signs (=) when value is null
|
|
96
|
-
- [**#6**](https://github.com/hapijs/qs/issues/6) Minor grammar fix in README
|
|
97
|
-
|
|
98
|
-
## [**1.0.2**](https://github.com/hapijs/qs/issues?milestone=2&state=closed)
|
|
99
|
-
- [**#5**](https://github.com/hapijs/qs/issues/5) array holes incorrectly copied into object on large index
|
|
103
|
+
## [**1.0.2**](https://github.com/ljharb/qs/issues?milestone=2&state=closed)
|
|
104
|
+
- [**#5**](https://github.com/ljharb/qs/issues/5) array holes incorrectly copied into object on large index
|
package/dist/qs.js
CHANGED
|
@@ -44,23 +44,18 @@ internals.parseValues = function (str, options) {
|
|
|
44
44
|
var part = parts[i];
|
|
45
45
|
var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
|
|
46
46
|
|
|
47
|
+
var key, val;
|
|
47
48
|
if (pos === -1) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
key = Utils.decode(part);
|
|
50
|
+
val = options.strictNullHandling ? null : '';
|
|
51
|
+
} else {
|
|
52
|
+
key = Utils.decode(part.slice(0, pos));
|
|
53
|
+
val = Utils.decode(part.slice(pos + 1));
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
59
|
-
obj[key] = val;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
obj[key] = [].concat(obj[key]).concat(val);
|
|
63
|
-
}
|
|
55
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
56
|
+
obj[key] = [].concat(obj[key]).concat(val);
|
|
57
|
+
} else {
|
|
58
|
+
obj[key] = val;
|
|
64
59
|
}
|
|
65
60
|
}
|
|
66
61
|
|
|
@@ -234,7 +229,7 @@ var internals = {
|
|
|
234
229
|
};
|
|
235
230
|
|
|
236
231
|
|
|
237
|
-
internals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter) {
|
|
232
|
+
internals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort) {
|
|
238
233
|
|
|
239
234
|
if (typeof filter === 'function') {
|
|
240
235
|
obj = filter(prefix, obj);
|
|
@@ -269,7 +264,14 @@ internals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHand
|
|
|
269
264
|
return values;
|
|
270
265
|
}
|
|
271
266
|
|
|
272
|
-
var objKeys
|
|
267
|
+
var objKeys;
|
|
268
|
+
if (Array.isArray(filter)) {
|
|
269
|
+
objKeys = filter;
|
|
270
|
+
} else {
|
|
271
|
+
var keys = Object.keys(obj);
|
|
272
|
+
objKeys = sort ? keys.sort(sort) : keys;
|
|
273
|
+
}
|
|
274
|
+
|
|
273
275
|
for (var i = 0, il = objKeys.length; i < il; ++i) {
|
|
274
276
|
var key = objKeys[i];
|
|
275
277
|
|
|
@@ -298,6 +300,7 @@ module.exports = function (obj, options) {
|
|
|
298
300
|
var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling;
|
|
299
301
|
var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : internals.skipNulls;
|
|
300
302
|
var encode = typeof options.encode === 'boolean' ? options.encode : internals.encode;
|
|
303
|
+
var sort = typeof options.sort === 'function' ? options.sort : null;
|
|
301
304
|
var objKeys;
|
|
302
305
|
var filter;
|
|
303
306
|
if (typeof options.filter === 'function') {
|
|
@@ -333,6 +336,10 @@ module.exports = function (obj, options) {
|
|
|
333
336
|
objKeys = Object.keys(obj);
|
|
334
337
|
}
|
|
335
338
|
|
|
339
|
+
if (sort) {
|
|
340
|
+
objKeys.sort(sort);
|
|
341
|
+
}
|
|
342
|
+
|
|
336
343
|
for (var i = 0, il = objKeys.length; i < il; ++i) {
|
|
337
344
|
var key = objKeys[i];
|
|
338
345
|
|
|
@@ -342,7 +349,7 @@ module.exports = function (obj, options) {
|
|
|
342
349
|
continue;
|
|
343
350
|
}
|
|
344
351
|
|
|
345
|
-
keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter));
|
|
352
|
+
keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort));
|
|
346
353
|
}
|
|
347
354
|
|
|
348
355
|
return keys.join(delimiter);
|
package/lib/parse.js
CHANGED
|
@@ -26,23 +26,18 @@ internals.parseValues = function (str, options) {
|
|
|
26
26
|
var part = parts[i];
|
|
27
27
|
var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
|
|
28
28
|
|
|
29
|
+
var key, val;
|
|
29
30
|
if (pos === -1) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
key = Utils.decode(part);
|
|
32
|
+
val = options.strictNullHandling ? null : '';
|
|
33
|
+
} else {
|
|
34
|
+
key = Utils.decode(part.slice(0, pos));
|
|
35
|
+
val = Utils.decode(part.slice(pos + 1));
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
41
|
-
obj[key] = val;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
obj[key] = [].concat(obj[key]).concat(val);
|
|
45
|
-
}
|
|
37
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
38
|
+
obj[key] = [].concat(obj[key]).concat(val);
|
|
39
|
+
} else {
|
|
40
|
+
obj[key] = val;
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
43
|
|
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/hapijs/qs",
|
|
5
|
-
"version": "5.2.
|
|
5
|
+
"version": "5.2.1",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/hapijs/qs.git"
|
package/test/parse.js
CHANGED
|
@@ -232,8 +232,13 @@ describe('parse()', function () {
|
|
|
232
232
|
it('allows for empty strings in arrays', function (done) {
|
|
233
233
|
|
|
234
234
|
expect(Qs.parse('a[]=b&a[]=&a[]=c')).to.deep.equal({ a: ['b', '', 'c'] });
|
|
235
|
-
|
|
236
|
-
expect(Qs.parse('a[0]=b&a[1]
|
|
235
|
+
|
|
236
|
+
expect(Qs.parse('a[0]=b&a[1]&a[2]=c&a[19]=', { strictNullHandling: true, arrayLimit: 20 })).to.deep.equal({ a: ['b', null, 'c', ''] });
|
|
237
|
+
expect(Qs.parse('a[]=b&a[]&a[]=c&a[]=', { strictNullHandling: true, arrayLimit: 0 })).to.deep.equal({ a: ['b', null, 'c', ''] });
|
|
238
|
+
|
|
239
|
+
expect(Qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]', { strictNullHandling: true, arrayLimit: 20 })).to.deep.equal({ a: ['b', '', 'c', null] });
|
|
240
|
+
expect(Qs.parse('a[]=b&a[]=&a[]=c&a[]', { strictNullHandling: true, arrayLimit: 0 })).to.deep.equal({ a: ['b', '', 'c', null] });
|
|
241
|
+
|
|
237
242
|
expect(Qs.parse('a[]=&a[]=b&a[]=c')).to.deep.equal({ a: ['', 'b', 'c'] });
|
|
238
243
|
done();
|
|
239
244
|
});
|