qs 6.4.0 → 6.5.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 ADDED
@@ -0,0 +1,30 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 4
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+ max_line_length = 140
11
+
12
+ [test/*]
13
+ max_line_length = off
14
+
15
+ [*.md]
16
+ max_line_length = off
17
+
18
+ [*.json]
19
+ max_line_length = off
20
+
21
+ [Makefile]
22
+ max_line_length = off
23
+
24
+ [CHANGELOG.md]
25
+ indent_style = space
26
+ indent_size = 2
27
+
28
+ [LICENSE]
29
+ indent_size = 2
30
+ max_line_length = off
package/.eslintrc CHANGED
@@ -4,15 +4,16 @@
4
4
  "extends": "@ljharb",
5
5
 
6
6
  "rules": {
7
- "complexity": [2, 26],
7
+ "complexity": 0,
8
8
  "consistent-return": 1,
9
+ "func-name-matching": 0,
9
10
  "id-length": [2, { "min": 1, "max": 25, "properties": "never" }],
10
11
  "indent": [2, 4],
11
12
  "max-params": [2, 12],
12
- "max-statements": [2, 43],
13
+ "max-statements": [2, 45],
13
14
  "no-continue": 1,
14
15
  "no-magic-numbers": 0,
15
16
  "no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"],
16
- "operator-linebreak": [2, "after"],
17
+ "operator-linebreak": [2, "before"],
17
18
  }
18
19
  }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ ## **6.5.2**
2
+ - [Fix] use `safer-buffer` instead of `Buffer` constructor
3
+ - [Refactor] utils: `module.exports` one thing, instead of mutating `exports` (#230)
4
+ - [Dev Deps] update `browserify`, `eslint`, `iconv-lite`, `safer-buffer`, `tape`, `browserify`
5
+
6
+ ## **6.5.1**
7
+ - [Fix] Fix parsing & compacting very deep objects (#224)
8
+ - [Refactor] name utils functions
9
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`
10
+ - [Tests] up to `node` `v8.4`; use `nvm install-latest-npm` so newer npm doesn’t break older node
11
+ - [Tests] Use precise dist for Node.js 0.6 runtime (#225)
12
+ - [Tests] make 0.6 required, now that it’s passing
13
+ - [Tests] on `node` `v8.2`; fix npm on node 0.6
14
+
15
+ ## **6.5.0**
16
+ - [New] add `utils.assign`
17
+ - [New] pass default encoder/decoder to custom encoder/decoder functions (#206)
18
+ - [New] `parse`/`stringify`: add `ignoreQueryPrefix`/`addQueryPrefix` options, respectively (#213)
19
+ - [Fix] Handle stringifying empty objects with addQueryPrefix (#217)
20
+ - [Fix] do not mutate `options` argument (#207)
21
+ - [Refactor] `parse`: cache index to reuse in else statement (#182)
22
+ - [Docs] add various badges to readme (#208)
23
+ - [Dev Deps] update `eslint`, `browserify`, `iconv-lite`, `tape`
24
+ - [Tests] up to `node` `v8.1`, `v7.10`, `v6.11`; npm v4.6 breaks on node < v1; npm v5+ breaks on node < v4
25
+ - [Tests] add `editorconfig-tools`
26
+
1
27
  ## **6.4.0**
2
28
  - [New] `qs.stringify`: add `encodeValuesOnly` option
3
29
  - [Fix] follow `allowPrototypes` option during merge (#201, #201)
@@ -7,6 +33,13 @@
7
33
  - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
8
34
  - [eslint] reduce warnings
9
35
 
36
+ ## **6.3.2**
37
+ - [Fix] follow `allowPrototypes` option during merge (#201, #200)
38
+ - [Dev Deps] update `eslint`
39
+ - [Fix] chmod a-x
40
+ - [Fix] support keys starting with brackets (#202, #200)
41
+ - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
42
+
10
43
  ## **6.3.1**
11
44
  - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties (thanks, @snyk!)
12
45
  - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `browserify`, `iconv-lite`, `qs-iconv`, `tape`
@@ -33,6 +66,12 @@
33
66
  - [Tests] skip Object.create tests when null objects are not available
34
67
  - [Tests] Turn on eslint for test files (#175)
35
68
 
69
+ ## **6.2.3**
70
+ - [Fix] follow `allowPrototypes` option during merge (#201, #200)
71
+ - [Fix] chmod a-x
72
+ - [Fix] support keys starting with brackets (#202, #200)
73
+ - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
74
+
36
75
  ## **6.2.2**
37
76
  - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
38
77
 
@@ -48,6 +87,12 @@
48
87
  - [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160)
49
88
  - [Fix] fix compacting of nested sparse arrays (#150)
50
89
 
90
+ ## **6.1.2
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
+
51
96
  ## **6.1.1**
52
97
  - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
53
98
 
@@ -56,6 +101,12 @@
56
101
  - [Fix] "sort" option should work at a depth of 3 or more (#151)
57
102
  - [Fix] Restore `dist` directory; will be removed in v7 (#148)
58
103
 
104
+ ## **6.0.4**
105
+ - [Fix] follow `allowPrototypes` option during merge (#201, #200)
106
+ - [Fix] chmod a-x
107
+ - [Fix] support keys starting with brackets (#202, #200)
108
+ - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
109
+
59
110
  ## **6.0.3**
60
111
  - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
61
112
  - [Fix] Restore `dist` directory; will be removed in v7 (#148)
package/README.md CHANGED
@@ -1,8 +1,14 @@
1
- # qs
1
+ # qs <sup>[![Version Badge][2]][1]</sup>
2
2
 
3
- A querystring parsing and stringifying library with some added security.
3
+ [![Build Status][3]][4]
4
+ [![dependency status][5]][6]
5
+ [![dev dependency status][7]][8]
6
+ [![License][license-image]][license-url]
7
+ [![Downloads][downloads-image]][downloads-url]
8
+
9
+ [![npm badge][11]][1]
4
10
 
5
- [![Build Status](https://api.travis-ci.org/ljharb/qs.svg)](http://travis-ci.org/ljharb/qs)
11
+ A querystring parsing and stringifying library with some added security.
6
12
 
7
13
  Lead Maintainer: [Jordan Harband](https://github.com/ljharb)
8
14
 
@@ -33,9 +39,9 @@ For example, the string `'foo[bar]=baz'` converts to:
33
39
 
34
40
  ```javascript
35
41
  assert.deepEqual(qs.parse('foo[bar]=baz'), {
36
- foo: {
37
- bar: 'baz'
38
- }
42
+ foo: {
43
+ bar: 'baz'
44
+ }
39
45
  });
40
46
  ```
41
47
 
@@ -57,7 +63,7 @@ URI encoded strings work too:
57
63
 
58
64
  ```javascript
59
65
  assert.deepEqual(qs.parse('a%5Bb%5D=c'), {
60
- a: { b: 'c' }
66
+ a: { b: 'c' }
61
67
  });
62
68
  ```
63
69
 
@@ -65,11 +71,11 @@ You can also nest your objects, like `'foo[bar][baz]=foobarbaz'`:
65
71
 
66
72
  ```javascript
67
73
  assert.deepEqual(qs.parse('foo[bar][baz]=foobarbaz'), {
68
- foo: {
69
- bar: {
70
- baz: 'foobarbaz'
74
+ foo: {
75
+ bar: {
76
+ baz: 'foobarbaz'
77
+ }
71
78
  }
72
- }
73
79
  });
74
80
  ```
75
81
 
@@ -78,19 +84,19 @@ By default, when nesting objects **qs** will only parse up to 5 children deep. T
78
84
 
79
85
  ```javascript
80
86
  var expected = {
81
- a: {
82
- b: {
83
- c: {
84
- d: {
85
- e: {
86
- f: {
87
- '[g][h][i]': 'j'
87
+ a: {
88
+ b: {
89
+ c: {
90
+ d: {
91
+ e: {
92
+ f: {
93
+ '[g][h][i]': 'j'
94
+ }
95
+ }
96
+ }
88
97
  }
89
- }
90
98
  }
91
- }
92
99
  }
93
- }
94
100
  };
95
101
  var string = 'a[b][c][d][e][f][g][h][i]=j';
96
102
  assert.deepEqual(qs.parse(string), expected);
@@ -112,6 +118,13 @@ var limited = qs.parse('a=b&c=d', { parameterLimit: 1 });
112
118
  assert.deepEqual(limited, { a: 'b' });
113
119
  ```
114
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
+
115
128
  An optional delimiter can also be passed:
116
129
 
117
130
  ```javascript
@@ -227,10 +240,10 @@ assert.equal(unencoded, 'a[b]=c');
227
240
 
228
241
  Encoding can be disabled for keys by setting the `encodeValuesOnly` option to `true`:
229
242
  ```javascript
230
- var encodedValues = qs.stringify(
231
- { a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
232
- { encodeValuesOnly: true }
233
- )
243
+ var encodedValues = qs.stringify(
244
+ { a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
245
+ { encodeValuesOnly: true }
246
+ );
234
247
  assert.equal(encodedValues,'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h');
235
248
  ```
236
249
 
@@ -238,8 +251,8 @@ This encoding can also be replaced by a custom encoding method set as `encoder`
238
251
 
239
252
  ```javascript
240
253
  var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str) {
241
- // Passed in values `a`, `b`, `c`
242
- return // Return encoded string
254
+ // Passed in values `a`, `b`, `c`
255
+ return // Return encoded string
243
256
  }})
244
257
  ```
245
258
 
@@ -249,8 +262,8 @@ Analogue to the `encoder` there is a `decoder` option for `parse` to override de
249
262
 
250
263
  ```javascript
251
264
  var decoded = qs.parse('x=z', { decoder: function (str) {
252
- // Passed in values `x`, `z`
253
- return // Return decoded string
265
+ // Passed in values `x`, `z`
266
+ return // Return decoded string
254
267
  }})
255
268
  ```
256
269
 
@@ -317,6 +330,12 @@ Properties that are set to `undefined` will be omitted entirely:
317
330
  assert.equal(qs.stringify({ a: null, b: undefined }), 'a=');
318
331
  ```
319
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
+
320
339
  The delimiter may be overridden with stringify as well:
321
340
 
322
341
  ```javascript
@@ -338,7 +357,7 @@ You may use the `sort` option to affect the order of parameter keys:
338
357
 
339
358
  ```javascript
340
359
  function alphabeticalSort(a, b) {
341
- return a.localeCompare(b);
360
+ return a.localeCompare(b);
342
361
  }
343
362
  assert.equal(qs.stringify({ a: 'c', z: 'y', b : 'f' }, { sort: alphabeticalSort }), 'a=c&b=f&z=y');
344
363
  ```
@@ -349,17 +368,17 @@ pass an array, it will be used to select properties and array indices for string
349
368
 
350
369
  ```javascript
351
370
  function filterFunc(prefix, value) {
352
- if (prefix == 'b') {
353
- // Return an `undefined` value to omit a property.
354
- return;
355
- }
356
- if (prefix == 'e[f]') {
357
- return value.getTime();
358
- }
359
- if (prefix == 'e[g][0]') {
360
- return value * 2;
361
- }
362
- 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;
363
382
  }
364
383
  qs.stringify({ a: 'b', c: 'd', e: { f: new Date(123), g: [2] } }, { filter: filterFunc });
365
384
  // 'a=b&c=d&e[f]=123&e[g][0]=4'
@@ -438,3 +457,19 @@ assert.equal(qs.stringify({ a: 'b c' }), 'a=b%20c');
438
457
  assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC3986' }), 'a=b%20c');
439
458
  assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC1738' }), 'a=b+c');
440
459
  ```
460
+
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
473
+ [license-url]: LICENSE
474
+ [downloads-image]: http://img.shields.io/npm/dm/qs.svg
475
+ [downloads-url]: http://npm-stat.com/charts.html?package=qs