qs 6.9.5 → 6.10.2

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
@@ -8,6 +8,7 @@ charset = utf-8
8
8
  trim_trailing_whitespace = true
9
9
  insert_final_newline = true
10
10
  max_line_length = 160
11
+ quote_type = single
11
12
 
12
13
  [test/*]
13
14
  max_line_length = off
package/.eslintrc CHANGED
@@ -10,13 +10,12 @@
10
10
  "id-length": [2, { "min": 1, "max": 25, "properties": "never" }],
11
11
  "indent": [2, 4],
12
12
  "max-lines-per-function": [2, { "max": 150 }],
13
- "max-params": [2, 14],
13
+ "max-params": [2, 15],
14
14
  "max-statements": [2, 52],
15
15
  "multiline-comment-style": 0,
16
16
  "no-continue": 1,
17
17
  "no-magic-numbers": 0,
18
18
  "no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"],
19
- "operator-linebreak": [2, "before"],
20
19
  },
21
20
 
22
21
  "overrides": [
package/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ ## **6.10.2**
2
+ - [Fix] `stringify`: actually fix cyclic references (#426)
3
+ - [Fix] `stringify`: avoid encoding arrayformat comma when `encodeValuesOnly = true` (#424)
4
+ - [readme] remove travis badge; add github actions/codecov badges; update URLs
5
+ - [Docs] add note and links for coercing primitive values (#408)
6
+ - [actions] update codecov uploader
7
+ - [actions] update workflows
8
+ - [Tests] clean up stringify tests slightly
9
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `safe-publish-latest`, `tape`
10
+
11
+ ## **6.10.1**
12
+ - [Fix] `stringify`: avoid exception on repeated object values (#402)
13
+
14
+ ## **6.10.0**
15
+ - [New] `stringify`: throw on cycles, instead of an infinite loop (#395, #394, #393)
16
+ - [New] `parse`: add `allowSparse` option for collapsing arrays with missing indices (#312)
17
+ - [meta] fix README.md (#399)
18
+ - [meta] only run `npm run dist` in publish, not install
19
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `has-symbols`, `tape`
20
+ - [Tests] fix tests on node v0.6
21
+ - [Tests] use `ljharb/actions/node/install` instead of `ljharb/actions/node/run`
22
+ - [Tests] Revert "[meta] ignore eclint transitive audit warning"
23
+
24
+ ## **6.9.6**
25
+ - [Fix] restore `dist` dir; mistakenly removed in d4f6c32
26
+
1
27
  ## **6.9.5**
2
28
  - [Fix] `stringify`: do not encode parens for RFC1738
3
29
  - [Fix] `stringify`: fix arrayFormat comma with empty array/objects (#350)
package/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # qs <sup>[![Version Badge][2]][1]</sup>
2
2
 
3
- [![Build Status][3]][4]
4
- [![dependency status][5]][6]
5
- [![dev dependency status][7]][8]
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]
6
7
  [![License][license-image]][license-url]
7
8
  [![Downloads][downloads-image]][downloads-url]
8
9
 
9
- [![npm badge][11]][1]
10
+ [![npm badge][npm-badge-png]][package-url]
10
11
 
11
12
  A querystring parsing and stringifying library with some added security.
12
13
 
@@ -227,6 +228,13 @@ var noSparse = qs.parse('a[1]=b&a[15]=c');
227
228
  assert.deepEqual(noSparse, { a: ['b', 'c'] });
228
229
  ```
229
230
 
231
+ You may also use `allowSparse` option to parse sparse arrays:
232
+
233
+ ```javascript
234
+ var sparseArray = qs.parse('a[1]=2&a[3]=5', { allowSparse: true });
235
+ assert.deepEqual(sparseArray, { a: [, '2', , '5'] });
236
+ ```
237
+
230
238
  Note that an empty string is also a value, and will be preserved:
231
239
 
232
240
  ```javascript
@@ -280,6 +288,17 @@ assert.deepEqual(arraysOfObjects, { a: ['b', 'c'] })
280
288
  ```
281
289
  (_this cannot convert nested objects, such as `a={b:1},{c:d}`_)
282
290
 
291
+ ### Parsing primitive/scalar values (numbers, booleans, null, etc)
292
+
293
+ By default, all values are parsed as strings. This behavior will not change and is explained in [issue #91](https://github.com/ljharb/qs/issues/91).
294
+
295
+ ```javascript
296
+ var primitiveValues = qs.parse('a=15&b=true&c=null');
297
+ assert.deepEqual(primitiveValues, { a: '15', b: 'true', c: 'null' });
298
+ ```
299
+
300
+ If you wish to auto-convert values which look like numbers, booleans, and other values into their primitive counterparts, you can use the [query-types Express JS middleware](https://github.com/xpepermint/query-types) which will auto-convert all request query parameters.
301
+
283
302
  ### Stringifying
284
303
 
285
304
  [](#preventEval)
@@ -345,7 +364,7 @@ var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str, defaultE
345
364
  The type argument is also provided to the decoder:
346
365
 
347
366
  ```javascript
348
- var decoded = qs.parse('x=z', { decoder: function (str, defaultEncoder, charset, type) {
367
+ var decoded = qs.parse('x=z', { decoder: function (str, defaultDecoder, charset, type) {
349
368
  if (type === 'key') {
350
369
  return // Decoded key
351
370
  } else if (type === 'value') {
@@ -587,18 +606,18 @@ Available as part of the Tidelift Subscription
587
606
 
588
607
  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)
589
608
 
590
- [1]: https://npmjs.org/package/qs
591
- [2]: http://versionbadg.es/ljharb/qs.svg
592
- [3]: https://api.travis-ci.org/ljharb/qs.svg
593
- [4]: https://travis-ci.org/ljharb/qs
594
- [5]: https://david-dm.org/ljharb/qs.svg
595
- [6]: https://david-dm.org/ljharb/qs
596
- [7]: https://david-dm.org/ljharb/qs/dev-status.svg
597
- [8]: https://david-dm.org/ljharb/qs?type=dev
598
- [9]: https://ci.testling.com/ljharb/qs.png
599
- [10]: https://ci.testling.com/ljharb/qs
600
- [11]: https://nodei.co/npm/qs.png?downloads=true&stars=true
601
- [license-image]: http://img.shields.io/npm/l/qs.svg
609
+ [package-url]: https://npmjs.org/package/qs
610
+ [npm-version-svg]: https://versionbadg.es/ljharb/qs.svg
611
+ [deps-svg]: https://david-dm.org/ljharb/qs.svg
612
+ [deps-url]: https://david-dm.org/ljharb/qs
613
+ [dev-deps-svg]: https://david-dm.org/ljharb/qs/dev-status.svg
614
+ [dev-deps-url]: https://david-dm.org/ljharb/qs#info=devDependencies
615
+ [npm-badge-png]: https://nodei.co/npm/qs.png?downloads=true&stars=true
616
+ [license-image]: https://img.shields.io/npm/l/qs.svg
602
617
  [license-url]: LICENSE
603
- [downloads-image]: http://img.shields.io/npm/dm/qs.svg
604
- [downloads-url]: http://npm-stat.com/charts.html?package=qs
618
+ [downloads-image]: https://img.shields.io/npm/dm/qs.svg
619
+ [downloads-url]: https://npm-stat.com/charts.html?package=qs
620
+ [codecov-image]: https://codecov.io/gh/ljharb/qs/branch/main/graphs/badge.svg
621
+ [codecov-url]: https://app.codecov.io/gh/ljharb/qs/
622
+ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/qs
623
+ [actions-url]: https://github.com/ljharb/qs/actions