qs 6.10.6 → 6.10.7

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.10.7**
2
+ - [Fix] fix regressions from robustness refactor
3
+ - [actions] update reusable workflows
4
+
1
5
  ## **6.10.6**
2
6
  - [Robustness] avoid `.push`, use `void`
3
7
  - [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
package/dist/qs.js CHANGED
@@ -234,7 +234,7 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesPars
234
234
  // If there's a remainder, just add whatever is left
235
235
 
236
236
  if (segment) {
237
- keys[keys.length] = '[' + key.slice(segment.index + ']');
237
+ keys[keys.length] = '[' + key.slice(segment.index) + ']';
238
238
  }
239
239
 
240
240
  return parseObject(keys, val, options, valuesParsed);
@@ -633,7 +633,7 @@ var isArray = Array.isArray;
633
633
  var hexTable = (function () {
634
634
  var array = [];
635
635
  for (var i = 0; i < 256; ++i) {
636
- array[array.length] = '%' + ((i < 16 ? '0' : '' + i.toString(16)).toUpperCase());
636
+ array[array.length] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
637
637
  }
638
638
 
639
639
  return array;
package/lib/parse.js CHANGED
@@ -195,7 +195,7 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesPars
195
195
  // If there's a remainder, just add whatever is left
196
196
 
197
197
  if (segment) {
198
- keys[keys.length] = '[' + key.slice(segment.index + ']');
198
+ keys[keys.length] = '[' + key.slice(segment.index) + ']';
199
199
  }
200
200
 
201
201
  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.10.6",
5
+ "version": "6.10.7",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/ljharb/qs.git"
package/test/parse.js CHANGED
@@ -84,6 +84,15 @@ test('parse()', function (t) {
84
84
  st.end();
85
85
  });
86
86
 
87
+ t.test('correctly computes the remainder when depth is exceeded', function (st) {
88
+ st.deepEqual(
89
+ qs.parse('a[b][c][d][e]=f', { depth: 2 }),
90
+ { a: { b: { c: { '[d][e]': 'f' } } } },
91
+ 'the remainder is "[d][e]", not the full original key'
92
+ );
93
+ st.end();
94
+ });
95
+
87
96
  t.test('uses original key when depth = 0', function (st) {
88
97
  st.deepEqual(qs.parse('a[0]=b&a[1]=c', { depth: 0 }), { 'a[0]': 'b', 'a[1]': 'c' });
89
98
  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
@@ -21,6 +21,12 @@ test('stringify()', function (t) {
21
21
  st.end();
22
22
  });
23
23
 
24
+ t.test('correctly encodes low-byte characters', function (st) {
25
+ st.equal(qs.stringify({ a: String.fromCharCode(1) }), 'a=%01', 'encodes 0x01');
26
+ st.equal(qs.stringify({ a: String.fromCharCode(15) }), 'a=%0F', 'encodes 0x0F');
27
+ st.end();
28
+ });
29
+
24
30
  t.test('stringifies falsy values', function (st) {
25
31
  st.equal(qs.stringify(undefined), '');
26
32
  st.equal(qs.stringify(null), '');