qs 6.9.0 → 6.9.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 +7 -0
- package/dist/qs.js +7 -1
- package/lib/parse.js +6 -1
- package/lib/utils.js +1 -0
- package/package.json +6 -3
- package/test/parse.js +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## **6.9.1**
|
|
2
|
+
- [Fix] `parse`: with comma true, handle field that holds an array of arrays (#335)
|
|
3
|
+
- [Fix] `parse`: with comma true, do not split non-string values (#334)
|
|
4
|
+
- [meta] add `funding` field
|
|
5
|
+
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`
|
|
6
|
+
- [Tests] use shared travis-ci config
|
|
7
|
+
|
|
1
8
|
## **6.9.0**
|
|
2
9
|
- [New] `parse`/`stringify`: Pass extra key/value argument to `decoder` (#333)
|
|
3
10
|
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `evalmd`
|
package/dist/qs.js
CHANGED
|
@@ -45,6 +45,7 @@ module.exports = {
|
|
|
45
45
|
var utils = require('./utils');
|
|
46
46
|
|
|
47
47
|
var has = Object.prototype.hasOwnProperty;
|
|
48
|
+
var isArray = Array.isArray;
|
|
48
49
|
|
|
49
50
|
var defaults = {
|
|
50
51
|
allowDots: false,
|
|
@@ -125,10 +126,14 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
125
126
|
val = interpretNumericEntities(val);
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
if (val && options.comma && val.indexOf(',') > -1) {
|
|
129
|
+
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
|
|
129
130
|
val = val.split(',');
|
|
130
131
|
}
|
|
131
132
|
|
|
133
|
+
if (part.indexOf('[]=') > -1) {
|
|
134
|
+
val = isArray(val) ? [val] : val;
|
|
135
|
+
}
|
|
136
|
+
|
|
132
137
|
if (has.call(obj, key)) {
|
|
133
138
|
obj[key] = utils.combine(obj[key], val);
|
|
134
139
|
} else {
|
|
@@ -611,6 +616,7 @@ var arrayToObject = function arrayToObject(source, options) {
|
|
|
611
616
|
};
|
|
612
617
|
|
|
613
618
|
var merge = function merge(target, source, options) {
|
|
619
|
+
/* eslint no-param-reassign: 0 */
|
|
614
620
|
if (!source) {
|
|
615
621
|
return target;
|
|
616
622
|
}
|
package/lib/parse.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var utils = require('./utils');
|
|
4
4
|
|
|
5
5
|
var has = Object.prototype.hasOwnProperty;
|
|
6
|
+
var isArray = Array.isArray;
|
|
6
7
|
|
|
7
8
|
var defaults = {
|
|
8
9
|
allowDots: false,
|
|
@@ -83,10 +84,14 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
83
84
|
val = interpretNumericEntities(val);
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
if (val && options.comma && val.indexOf(',') > -1) {
|
|
87
|
+
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
|
|
87
88
|
val = val.split(',');
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
if (part.indexOf('[]=') > -1) {
|
|
92
|
+
val = isArray(val) ? [val] : val;
|
|
93
|
+
}
|
|
94
|
+
|
|
90
95
|
if (has.call(obj, key)) {
|
|
91
96
|
obj[key] = utils.combine(obj[key], val);
|
|
92
97
|
} else {
|
package/lib/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
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.9.
|
|
5
|
+
"version": "6.9.1",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/ljharb/qs.git"
|
|
9
9
|
},
|
|
10
|
+
"funding": {
|
|
11
|
+
"url": "https://github.com/sponsors/ljharb"
|
|
12
|
+
},
|
|
10
13
|
"main": "lib/index.js",
|
|
11
14
|
"contributors": [
|
|
12
15
|
{
|
|
@@ -28,11 +31,11 @@
|
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {},
|
|
30
33
|
"devDependencies": {
|
|
31
|
-
"@ljharb/eslint-config": "^
|
|
34
|
+
"@ljharb/eslint-config": "^15.0.0",
|
|
32
35
|
"browserify": "^16.5.0",
|
|
33
36
|
"covert": "^1.1.1",
|
|
34
37
|
"eclint": "^2.8.1",
|
|
35
|
-
"eslint": "^6.
|
|
38
|
+
"eslint": "^6.6.0",
|
|
36
39
|
"evalmd": "^0.0.19",
|
|
37
40
|
"for-each": "^0.3.3",
|
|
38
41
|
"has-symbols": "^1.0.0",
|
package/test/parse.js
CHANGED
|
@@ -400,6 +400,29 @@ test('parse()', function (t) {
|
|
|
400
400
|
st.end();
|
|
401
401
|
});
|
|
402
402
|
|
|
403
|
+
t.test('use number decoder, parses string that has one number with comma option enabled', function (st) {
|
|
404
|
+
var decoder = function (str, defaultDecoder, charset, type) {
|
|
405
|
+
if (!isNaN(Number(str))) {
|
|
406
|
+
return parseFloat(str);
|
|
407
|
+
}
|
|
408
|
+
return defaultDecoder(str, defaultDecoder, charset, type);
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
st.deepEqual(qs.parse('foo=1', { comma: true, decoder: decoder }), { foo: 1 });
|
|
412
|
+
st.deepEqual(qs.parse('foo=0', { comma: true, decoder: decoder }), { foo: 0 });
|
|
413
|
+
|
|
414
|
+
st.end();
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
t.test('parses brackets holds array of arrays when having two parts of strings with comma as array divider', function (st) {
|
|
418
|
+
st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=4,5,6', { comma: true }), { foo: [['1', '2', '3'], ['4', '5', '6']] });
|
|
419
|
+
st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=', { comma: true }), { foo: [['1', '2', '3'], ''] });
|
|
420
|
+
st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=,', { comma: true }), { foo: [['1', '2', '3'], ['', '']] });
|
|
421
|
+
st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=a', { comma: true }), { foo: [['1', '2', '3'], 'a'] });
|
|
422
|
+
|
|
423
|
+
st.end();
|
|
424
|
+
});
|
|
425
|
+
|
|
403
426
|
t.test('parses an object in dot notation', function (st) {
|
|
404
427
|
var input = {
|
|
405
428
|
'user.name': { 'pop[bob]': 3 },
|