qs 6.11.2 → 6.11.4
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 +11 -0
- package/README.md +9 -3
- package/dist/qs.js +684 -190
- package/lib/parse.js +4 -4
- package/lib/utils.js +7 -7
- package/package.json +1 -1
- package/test/parse.js +9 -0
- package/test/stringify.js +6 -0
package/lib/parse.js
CHANGED
|
@@ -52,7 +52,7 @@ var parseValues = function parseQueryStringValues(str, options) {
|
|
|
52
52
|
var obj = { __proto__: null };
|
|
53
53
|
|
|
54
54
|
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
|
|
55
|
-
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
|
|
55
|
+
var limit = options.parameterLimit === Infinity ? void undefined : options.parameterLimit;
|
|
56
56
|
var parts = cleanStr.split(options.delimiter, limit);
|
|
57
57
|
var skipIndex = -1; // Keep track of where the utf8 sentinel was found
|
|
58
58
|
var i;
|
|
@@ -177,7 +177,7 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesPars
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
keys.
|
|
180
|
+
keys[keys.length] = parent;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
// Loop through children appending to the array until we hit depth
|
|
@@ -190,13 +190,13 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesPars
|
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
keys.
|
|
193
|
+
keys[keys.length] = segment[1];
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
// If there's a remainder, just add whatever is left
|
|
197
197
|
|
|
198
198
|
if (segment) {
|
|
199
|
-
keys.
|
|
199
|
+
keys[keys.length] = '[' + key.slice(segment.index) + ']';
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
return parseObject(keys, val, options, valuesParsed);
|
package/lib/utils.js
CHANGED
|
@@ -8,7 +8,7 @@ var isArray = Array.isArray;
|
|
|
8
8
|
var hexTable = (function () {
|
|
9
9
|
var array = [];
|
|
10
10
|
for (var i = 0; i < 256; ++i) {
|
|
11
|
-
array.
|
|
11
|
+
array[array.length] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
return array;
|
|
@@ -24,7 +24,7 @@ var compactQueue = function compactQueue(queue) {
|
|
|
24
24
|
|
|
25
25
|
for (var j = 0; j < obj.length; ++j) {
|
|
26
26
|
if (typeof obj[j] !== 'undefined') {
|
|
27
|
-
compacted.
|
|
27
|
+
compacted[compacted.length] = obj[j];
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -52,7 +52,7 @@ var merge = function merge(target, source, options) {
|
|
|
52
52
|
|
|
53
53
|
if (typeof source !== 'object') {
|
|
54
54
|
if (isArray(target)) {
|
|
55
|
-
target.
|
|
55
|
+
target[target.length] = source;
|
|
56
56
|
} else if (target && typeof target === 'object') {
|
|
57
57
|
if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
|
|
58
58
|
target[source] = true;
|
|
@@ -80,7 +80,7 @@ var merge = function merge(target, source, options) {
|
|
|
80
80
|
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
81
81
|
target[i] = merge(targetItem, item, options);
|
|
82
82
|
} else {
|
|
83
|
-
target.
|
|
83
|
+
target[target.length] = item;
|
|
84
84
|
}
|
|
85
85
|
} else {
|
|
86
86
|
target[i] = item;
|
|
@@ -200,8 +200,8 @@ var compact = function compact(value) {
|
|
|
200
200
|
var key = keys[j];
|
|
201
201
|
var val = obj[key];
|
|
202
202
|
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
203
|
-
queue.
|
|
204
|
-
refs.
|
|
203
|
+
queue[queue.length] = { obj: obj, prop: key };
|
|
204
|
+
refs[refs.length] = val;
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
}
|
|
@@ -231,7 +231,7 @@ var maybeMap = function maybeMap(val, fn) {
|
|
|
231
231
|
if (isArray(val)) {
|
|
232
232
|
var mapped = [];
|
|
233
233
|
for (var i = 0; i < val.length; i += 1) {
|
|
234
|
-
mapped.
|
|
234
|
+
mapped[mapped.length] = fn(val[i]);
|
|
235
235
|
}
|
|
236
236
|
return mapped;
|
|
237
237
|
}
|
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.11.
|
|
5
|
+
"version": "6.11.4",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/ljharb/qs.git"
|
package/test/parse.js
CHANGED
|
@@ -89,6 +89,15 @@ test('parse()', function (t) {
|
|
|
89
89
|
st.end();
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
+
t.test('correctly computes the remainder when depth is exceeded', function (st) {
|
|
93
|
+
st.deepEqual(
|
|
94
|
+
qs.parse('a[b][c][d][e]=f', { depth: 2 }),
|
|
95
|
+
{ a: { b: { c: { '[d][e]': 'f' } } } },
|
|
96
|
+
'the remainder is "[d][e]", not the full original key'
|
|
97
|
+
);
|
|
98
|
+
st.end();
|
|
99
|
+
});
|
|
100
|
+
|
|
92
101
|
t.test('uses original key when depth = 0', function (st) {
|
|
93
102
|
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { depth: 0 }), { 'a[0]': 'b', 'a[1]': 'c' });
|
|
94
103
|
st.deepEqual(qs.parse('a[0][0]=b&a[0][1]=c&a[1]=d&e=2', { depth: 0 }), { 'a[0][0]': 'b', 'a[0][1]': 'c', 'a[1]': 'd', e: '2' });
|
package/test/stringify.js
CHANGED
|
@@ -22,6 +22,12 @@ test('stringify()', function (t) {
|
|
|
22
22
|
st.end();
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
+
t.test('correctly encodes low-byte characters', function (st) {
|
|
26
|
+
st.equal(qs.stringify({ a: String.fromCharCode(1) }), 'a=%01', 'encodes 0x01');
|
|
27
|
+
st.equal(qs.stringify({ a: String.fromCharCode(15) }), 'a=%0F', 'encodes 0x0F');
|
|
28
|
+
st.end();
|
|
29
|
+
});
|
|
30
|
+
|
|
25
31
|
t.test('stringifies falsy values', function (st) {
|
|
26
32
|
st.equal(qs.stringify(undefined), '');
|
|
27
33
|
st.equal(qs.stringify(null), '');
|