qs 6.11.3 → 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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## **6.11.4**
2
+ - [Fix] fix regressions from robustness refactor
3
+ - [actions] update reusable workflows
4
+
1
5
  ## **6.11.3**
2
6
  - [Robustness] avoid `.push`, use `void`
3
7
  - [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
package/dist/qs.js CHANGED
@@ -235,7 +235,7 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesPars
235
235
  // If there's a remainder, just add whatever is left
236
236
 
237
237
  if (segment) {
238
- keys[keys.length] = '[' + key.slice(segment.index + ']');
238
+ keys[keys.length] = '[' + key.slice(segment.index) + ']';
239
239
  }
240
240
 
241
241
  return parseObject(keys, val, options, valuesParsed);
@@ -635,7 +635,7 @@ var isArray = Array.isArray;
635
635
  var hexTable = (function () {
636
636
  var array = [];
637
637
  for (var i = 0; i < 256; ++i) {
638
- array[array.length] = '%' + ((i < 16 ? '0' : '' + i.toString(16)).toUpperCase());
638
+ array[array.length] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
639
639
  }
640
640
 
641
641
  return array;
package/lib/parse.js CHANGED
@@ -196,7 +196,7 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesPars
196
196
  // If there's a remainder, just add whatever is left
197
197
 
198
198
  if (segment) {
199
- keys[keys.length] = '[' + key.slice(segment.index + ']');
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[array.length] = '%' + ((i < 16 ? '0' : '' + i.toString(16)).toUpperCase());
11
+ array[array.length] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
12
12
  }
13
13
 
14
14
  return array;
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.3",
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), '');