qs 6.4.1 → 6.5.0

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/.editorconfig CHANGED
@@ -7,14 +7,12 @@ end_of_line = lf
7
7
  charset = utf-8
8
8
  trim_trailing_whitespace = true
9
9
  insert_final_newline = true
10
- max_line_length = 160
11
- quote_type = single
10
+ max_line_length = 140
12
11
 
13
12
  [test/*]
14
13
  max_line_length = off
15
14
 
16
15
  [*.md]
17
- indent_size = off
18
16
  max_line_length = off
19
17
 
20
18
  [*.json]
@@ -30,15 +28,3 @@ indent_size = 2
30
28
  [LICENSE]
31
29
  indent_size = 2
32
30
  max_line_length = off
33
-
34
- [coverage/**/*]
35
- indent_size = off
36
- indent_style = off
37
- indent = off
38
- max_line_length = off
39
-
40
- [dist/*]
41
- max_line_length = off
42
-
43
- [.nycrc]
44
- indent_style = tab
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ dist
package/.eslintrc CHANGED
@@ -3,35 +3,16 @@
3
3
 
4
4
  "extends": "@ljharb",
5
5
 
6
- "ignorePatterns": [
7
- "dist/",
8
- ],
9
-
10
6
  "rules": {
11
- "complexity": [2, 29],
7
+ "complexity": [2, 28],
12
8
  "consistent-return": 1,
13
- "func-name-matching": 0,
14
9
  "id-length": [2, { "min": 1, "max": 25, "properties": "never" }],
15
10
  "indent": [2, 4],
16
- "max-lines-per-function": 0,
17
11
  "max-params": [2, 12],
18
12
  "max-statements": [2, 45],
19
- "multiline-comment-style": 0,
20
13
  "no-continue": 1,
21
14
  "no-magic-numbers": 0,
22
- "no-param-reassign": 1,
23
15
  "no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"],
24
- },
25
-
26
- "overrides": [
27
- {
28
- "files": "test/**",
29
- "rules": {
30
- "max-lines-per-function": 0,
31
- "max-statements": 0,
32
- "no-extend-native": 0,
33
- "function-paren-newline": 0,
34
- },
35
- },
36
- ],
16
+ "operator-linebreak": [2, "before"],
17
+ }
37
18
  }
package/CHANGELOG.md CHANGED
@@ -1,23 +1,14 @@
1
- ## **6.4.1**
2
- - [Fix] `parse`: ignore `__proto__` keys (#428)
3
- - [Fix] fix for an impossible situation: when the formatter is called with a non-string value
4
- - [Fix] use `safer-buffer` instead of `Buffer` constructor
5
- - [Fix] `utils.merge`: avoid a crash with a null target and an array source
6
- - [Fix]` `utils.merge`: avoid a crash with a null target and a truthy non-array source
7
- - [Fix] `stringify`: fix a crash with `strictNullHandling` and a custom `filter`/`serializeDate` (#279)
8
- - [Fix] `utils`: `merge`: fix crash when `source` is a truthy primitive & no options are provided
9
- - [Fix] when `parseArrays` is false, properly handle keys ending in `[]`
10
- - [Robustness] `stringify`: avoid relying on a global `undefined` (#427)
11
- - [Refactor] use cached `Array.isArray`
12
- - [Refactor] `stringify`: Avoid arr = arr.concat(...), push to the existing instance (#269)
13
- - [readme] remove travis badge; add github actions/codecov badges; update URLs
14
- - [Docs] Clarify the need for "arrayLimit" option
15
- - [meta] fix README.md (#399)
16
- - [meta] Clean up license text so it’s properly detected as BSD-3-Clause
17
- - [meta] add FUNDING.yml
18
- - [actions] backport actions from main
19
- - [Tests] remove nonexistent tape option
20
- - [Dev Deps] backport from main
1
+ ## **6.5.0**
2
+ - [New] add `utils.assign`
3
+ - [New] pass default encoder/decoder to custom encoder/decoder functions (#206)
4
+ - [New] `parse`/`stringify`: add `ignoreQueryPrefix`/`addQueryPrefix` options, respectively (#213)
5
+ - [Fix] Handle stringifying empty objects with addQueryPrefix (#217)
6
+ - [Fix] do not mutate `options` argument (#207)
7
+ - [Refactor] `parse`: cache index to reuse in else statement (#182)
8
+ - [Docs] add various badges to readme (#208)
9
+ - [Dev Deps] update `eslint`, `browserify`, `iconv-lite`, `tape`
10
+ - [Tests] up to `node` `v8.1`, `v7.10`, `v6.11`; npm v4.6 breaks on node < v1; npm v5+ breaks on node < v4
11
+ - [Tests] add `editorconfig-tools`
21
12
 
22
13
  ## **6.4.0**
23
14
  - [New] `qs.stringify`: add `encodeValuesOnly` option
@@ -28,6 +19,13 @@
28
19
  - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
29
20
  - [eslint] reduce warnings
30
21
 
22
+ ## **6.3.2**
23
+ - [Fix] follow `allowPrototypes` option during merge (#201, #200)
24
+ - [Dev Deps] update `eslint`
25
+ - [Fix] chmod a-x
26
+ - [Fix] support keys starting with brackets (#202, #200)
27
+ - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
28
+
31
29
  ## **6.3.1**
32
30
  - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties (thanks, @snyk!)
33
31
  - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `browserify`, `iconv-lite`, `qs-iconv`, `tape`
@@ -54,6 +52,12 @@
54
52
  - [Tests] skip Object.create tests when null objects are not available
55
53
  - [Tests] Turn on eslint for test files (#175)
56
54
 
55
+ ## **6.2.3**
56
+ - [Fix] follow `allowPrototypes` option during merge (#201, #200)
57
+ - [Fix] chmod a-x
58
+ - [Fix] support keys starting with brackets (#202, #200)
59
+ - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
60
+
57
61
  ## **6.2.2**
58
62
  - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
59
63
 
@@ -69,6 +73,12 @@
69
73
  - [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160)
70
74
  - [Fix] fix compacting of nested sparse arrays (#150)
71
75
 
76
+ ## **6.1.2
77
+ - [Fix] follow `allowPrototypes` option during merge (#201, #200)
78
+ - [Fix] chmod a-x
79
+ - [Fix] support keys starting with brackets (#202, #200)
80
+ - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
81
+
72
82
  ## **6.1.1**
73
83
  - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
74
84
 
@@ -77,6 +87,12 @@
77
87
  - [Fix] "sort" option should work at a depth of 3 or more (#151)
78
88
  - [Fix] Restore `dist` directory; will be removed in v7 (#148)
79
89
 
90
+ ## **6.0.4**
91
+ - [Fix] follow `allowPrototypes` option during merge (#201, #200)
92
+ - [Fix] chmod a-x
93
+ - [Fix] support keys starting with brackets (#202, #200)
94
+ - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
95
+
80
96
  ## **6.0.3**
81
97
  - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
82
98
  - [Fix] Restore `dist` directory; will be removed in v7 (#148)
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ Copyright (c) 2014 Nathan LaFreniere and other contributors.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ * Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ * The names of any contributors may not be used to endorse or promote
12
+ products derived from this software without specific prior written
13
+ permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ * * *
27
+
28
+ The complete list of contributors can be found at: https://github.com/hapijs/qs/graphs/contributors
package/README.md CHANGED
@@ -1,18 +1,15 @@
1
1
  # qs <sup>[![Version Badge][2]][1]</sup>
2
2
 
3
- [![github actions][actions-image]][actions-url]
4
- [![coverage][codecov-image]][codecov-url]
5
- [![dependency status][deps-svg]][deps-url]
6
- [![dev dependency status][dev-deps-svg]][dev-deps-url]
3
+ [![Build Status][3]][4]
4
+ [![dependency status][5]][6]
5
+ [![dev dependency status][7]][8]
7
6
  [![License][license-image]][license-url]
8
7
  [![Downloads][downloads-image]][downloads-url]
9
8
 
10
- [![npm badge][npm-badge-png]][package-url]
9
+ [![npm badge][11]][1]
11
10
 
12
11
  A querystring parsing and stringifying library with some added security.
13
12
 
14
- [![Build Status](https://api.travis-ci.org/ljharb/qs.svg)](http://travis-ci.org/ljharb/qs)
15
-
16
13
  Lead Maintainer: [Jordan Harband](https://github.com/ljharb)
17
14
 
18
15
  The **qs** module was originally created and maintained by [TJ Holowaychuk](https://github.com/visionmedia/node-querystring).
@@ -42,9 +39,9 @@ For example, the string `'foo[bar]=baz'` converts to:
42
39
 
43
40
  ```javascript
44
41
  assert.deepEqual(qs.parse('foo[bar]=baz'), {
45
- foo: {
46
- bar: 'baz'
47
- }
42
+ foo: {
43
+ bar: 'baz'
44
+ }
48
45
  });
49
46
  ```
50
47
 
@@ -66,7 +63,7 @@ URI encoded strings work too:
66
63
 
67
64
  ```javascript
68
65
  assert.deepEqual(qs.parse('a%5Bb%5D=c'), {
69
- a: { b: 'c' }
66
+ a: { b: 'c' }
70
67
  });
71
68
  ```
72
69
 
@@ -74,11 +71,11 @@ You can also nest your objects, like `'foo[bar][baz]=foobarbaz'`:
74
71
 
75
72
  ```javascript
76
73
  assert.deepEqual(qs.parse('foo[bar][baz]=foobarbaz'), {
77
- foo: {
78
- bar: {
79
- baz: 'foobarbaz'
74
+ foo: {
75
+ bar: {
76
+ baz: 'foobarbaz'
77
+ }
80
78
  }
81
- }
82
79
  });
83
80
  ```
84
81
 
@@ -87,19 +84,19 @@ By default, when nesting objects **qs** will only parse up to 5 children deep. T
87
84
 
88
85
  ```javascript
89
86
  var expected = {
90
- a: {
91
- b: {
92
- c: {
93
- d: {
94
- e: {
95
- f: {
96
- '[g][h][i]': 'j'
87
+ a: {
88
+ b: {
89
+ c: {
90
+ d: {
91
+ e: {
92
+ f: {
93
+ '[g][h][i]': 'j'
94
+ }
95
+ }
96
+ }
97
97
  }
98
- }
99
98
  }
100
- }
101
99
  }
102
- }
103
100
  };
104
101
  var string = 'a[b][c][d][e][f][g][h][i]=j';
105
102
  assert.deepEqual(qs.parse(string), expected);
@@ -121,6 +118,13 @@ var limited = qs.parse('a=b&c=d', { parameterLimit: 1 });
121
118
  assert.deepEqual(limited, { a: 'b' });
122
119
  ```
123
120
 
121
+ To bypass the leading question mark, use `ignoreQueryPrefix`:
122
+
123
+ ```javascript
124
+ var prefixed = qs.parse('?a=b&c=d', { ignoreQueryPrefix: true });
125
+ assert.deepEqual(prefixed, { a: 'b', c: 'd' });
126
+ ```
127
+
124
128
  An optional delimiter can also be passed:
125
129
 
126
130
  ```javascript
@@ -178,7 +182,7 @@ assert.deepEqual(withIndexedEmptyString, { a: ['b', '', 'c'] });
178
182
  ```
179
183
 
180
184
  **qs** will also limit specifying indices in an array to a maximum index of `20`. Any array members with an index of greater than `20` will
181
- instead be converted to an object with the index as the key. This is needed to handle cases when someone sent, for example, `a[999999999]` and it will take significant time to iterate over this huge array.
185
+ instead be converted to an object with the index as the key:
182
186
 
183
187
  ```javascript
184
188
  var withMaxIndex = qs.parse('a[100]=b');
@@ -236,10 +240,10 @@ assert.equal(unencoded, 'a[b]=c');
236
240
 
237
241
  Encoding can be disabled for keys by setting the `encodeValuesOnly` option to `true`:
238
242
  ```javascript
239
- var encodedValues = qs.stringify(
240
- { a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
241
- { encodeValuesOnly: true }
242
- )
243
+ var encodedValues = qs.stringify(
244
+ { a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
245
+ { encodeValuesOnly: true }
246
+ );
243
247
  assert.equal(encodedValues,'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h');
244
248
  ```
245
249
 
@@ -247,8 +251,8 @@ This encoding can also be replaced by a custom encoding method set as `encoder`
247
251
 
248
252
  ```javascript
249
253
  var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str) {
250
- // Passed in values `a`, `b`, `c`
251
- return // Return encoded string
254
+ // Passed in values `a`, `b`, `c`
255
+ return // Return encoded string
252
256
  }})
253
257
  ```
254
258
 
@@ -258,32 +262,8 @@ Analogue to the `encoder` there is a `decoder` option for `parse` to override de
258
262
 
259
263
  ```javascript
260
264
  var decoded = qs.parse('x=z', { decoder: function (str) {
261
- // Passed in values `x`, `z`
262
- return // Return decoded string
263
- }})
264
- ```
265
-
266
- You can encode keys and values using different logic by using the type argument provided to the encoder:
267
-
268
- ```javascript
269
- var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str, defaultEncoder, charset, type) {
270
- if (type === 'key') {
271
- return // Encoded key
272
- } else if (type === 'value') {
273
- return // Encoded value
274
- }
275
- }})
276
- ```
277
-
278
- The type argument is also provided to the decoder:
279
-
280
- ```javascript
281
- var decoded = qs.parse('x=z', { decoder: function (str, defaultDecoder, charset, type) {
282
- if (type === 'key') {
283
- return // Decoded key
284
- } else if (type === 'value') {
285
- return // Decoded value
286
- }
265
+ // Passed in values `x`, `z`
266
+ return // Return decoded string
287
267
  }})
288
268
  ```
289
269
 
@@ -350,6 +330,12 @@ Properties that are set to `undefined` will be omitted entirely:
350
330
  assert.equal(qs.stringify({ a: null, b: undefined }), 'a=');
351
331
  ```
352
332
 
333
+ The query string may optionally be prepended with a question mark:
334
+
335
+ ```javascript
336
+ assert.equal(qs.stringify({ a: 'b', c: 'd' }, { addQueryPrefix: true }), '?a=b&c=d');
337
+ ```
338
+
353
339
  The delimiter may be overridden with stringify as well:
354
340
 
355
341
  ```javascript
@@ -371,7 +357,7 @@ You may use the `sort` option to affect the order of parameter keys:
371
357
 
372
358
  ```javascript
373
359
  function alphabeticalSort(a, b) {
374
- return a.localeCompare(b);
360
+ return a.localeCompare(b);
375
361
  }
376
362
  assert.equal(qs.stringify({ a: 'c', z: 'y', b : 'f' }, { sort: alphabeticalSort }), 'a=c&b=f&z=y');
377
363
  ```
@@ -382,17 +368,17 @@ pass an array, it will be used to select properties and array indices for string
382
368
 
383
369
  ```javascript
384
370
  function filterFunc(prefix, value) {
385
- if (prefix == 'b') {
386
- // Return an `undefined` value to omit a property.
387
- return;
388
- }
389
- if (prefix == 'e[f]') {
390
- return value.getTime();
391
- }
392
- if (prefix == 'e[g][0]') {
393
- return value * 2;
394
- }
395
- return value;
371
+ if (prefix == 'b') {
372
+ // Return an `undefined` value to omit a property.
373
+ return;
374
+ }
375
+ if (prefix == 'e[f]') {
376
+ return value.getTime();
377
+ }
378
+ if (prefix == 'e[g][0]') {
379
+ return value * 2;
380
+ }
381
+ return value;
396
382
  }
397
383
  qs.stringify({ a: 'b', c: 'd', e: { f: new Date(123), g: [2] } }, { filter: filterFunc });
398
384
  // 'a=b&c=d&e[f]=123&e[g][0]=4'
@@ -472,28 +458,18 @@ assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC3986' }), 'a=b%20c');
472
458
  assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC1738' }), 'a=b+c');
473
459
  ```
474
460
 
475
- ## Security
476
-
477
- Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report.
478
-
479
- ## qs for enterprise
480
-
481
- Available as part of the Tidelift Subscription
482
-
483
- The maintainers of qs and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-qs?utm_source=npm-qs&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
484
-
485
- [package-url]: https://npmjs.org/package/qs
486
- [npm-version-svg]: https://versionbadg.es/ljharb/qs.svg
487
- [deps-svg]: https://david-dm.org/ljharb/qs.svg
488
- [deps-url]: https://david-dm.org/ljharb/qs
489
- [dev-deps-svg]: https://david-dm.org/ljharb/qs/dev-status.svg
490
- [dev-deps-url]: https://david-dm.org/ljharb/qs#info=devDependencies
491
- [npm-badge-png]: https://nodei.co/npm/qs.png?downloads=true&stars=true
492
- [license-image]: https://img.shields.io/npm/l/qs.svg
461
+ [1]: https://npmjs.org/package/qs
462
+ [2]: http://versionbadg.es/ljharb/qs.svg
463
+ [3]: https://api.travis-ci.org/ljharb/qs.svg
464
+ [4]: https://travis-ci.org/ljharb/qs
465
+ [5]: https://david-dm.org/ljharb/qs.svg
466
+ [6]: https://david-dm.org/ljharb/qs
467
+ [7]: https://david-dm.org/ljharb/qs/dev-status.svg
468
+ [8]: https://david-dm.org/ljharb/qs?type=dev
469
+ [9]: https://ci.testling.com/ljharb/qs.png
470
+ [10]: https://ci.testling.com/ljharb/qs
471
+ [11]: https://nodei.co/npm/qs.png?downloads=true&stars=true
472
+ [license-image]: http://img.shields.io/npm/l/qs.svg
493
473
  [license-url]: LICENSE
494
- [downloads-image]: https://img.shields.io/npm/dm/qs.svg
495
- [downloads-url]: https://npm-stat.com/charts.html?package=qs
496
- [codecov-image]: https://codecov.io/gh/ljharb/qs/branch/main/graphs/badge.svg
497
- [codecov-url]: https://app.codecov.io/gh/ljharb/qs/
498
- [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/qs
499
- [actions-url]: https://github.com/ljharb/qs/actions
474
+ [downloads-image]: http://img.shields.io/npm/dm/qs.svg
475
+ [downloads-url]: http://npm-stat.com/charts.html?package=qs