query-string 9.1.1 → 9.1.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.
Files changed (3) hide show
  1. package/base.js +10 -2
  2. package/package.json +1 -1
  3. package/readme.md +6 -30
package/base.js CHANGED
@@ -309,14 +309,22 @@ function parseValue(value, options, type) {
309
309
  return type(value);
310
310
  }
311
311
 
312
- if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
313
- return value.toLowerCase() === 'true';
312
+ if (type === 'string[]' && options.arrayFormat !== 'none' && typeof value === 'string') {
313
+ return [value];
314
+ }
315
+
316
+ if (type === 'number[]' && options.arrayFormat !== 'none' && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
317
+ return [Number(value)];
314
318
  }
315
319
 
316
320
  if (type === 'number' && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
317
321
  return Number(value);
318
322
  }
319
323
 
324
+ if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
325
+ return value.toLowerCase() === 'true';
326
+ }
327
+
320
328
  if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
321
329
  return Number(value);
322
330
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "query-string",
3
- "version": "9.1.1",
3
+ "version": "9.1.2",
4
4
  "description": "Parse and stringify URL query strings",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/query-string",
package/readme.md CHANGED
@@ -2,30 +2,6 @@
2
2
 
3
3
  > Parse and stringify URL [query strings](https://en.wikipedia.org/wiki/Query_string)
4
4
 
5
- <br>
6
-
7
- ---
8
-
9
- <div align="center">
10
- <p>
11
- <p>
12
- <sup>
13
- <a href="https://github.com/sponsors/sindresorhus">My open source work is supported by the community</a>
14
- </sup>
15
- </p>
16
- <sup>Special thanks to:</sup>
17
- <br>
18
- <br>
19
- <a href="https://standardresume.co/tech">
20
- <img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="180"/>
21
- </a>
22
- </p>
23
- </div>
24
-
25
- ---
26
-
27
- <br>
28
-
29
5
  ## Install
30
6
 
31
7
  ```sh
@@ -217,7 +193,7 @@ Parse the value as a boolean type instead of string type if it's a boolean.
217
193
  Type: `object`\
218
194
  Default: `{}`
219
195
 
220
- Specify a pre-defined schema to be used when parsing values. The types specified will take precedence over options such as: `parseNumber`, `parseBooleans`, and `arrayFormat`.
196
+ Specify a pre-defined schema to be used when parsing values. The types specified will take precedence over options such as: `parseNumbers`, `parseBooleans`, and `arrayFormat`.
221
197
 
222
198
  Use this feature to override the type of a value. This can be useful when the type is ambiguous such as a phone number.
223
199
 
@@ -225,7 +201,7 @@ It is possible to provide a custom function as the parameter type. The parameter
225
201
 
226
202
  Supported Types:
227
203
 
228
- - `'string'`: Parse `phoneNumber` as a string (overriding the `parseNumber` option):
204
+ - `'string'`: Parse `phoneNumber` as a string (overriding the `parseNumbers` option):
229
205
 
230
206
  ```js
231
207
  import queryString from 'query-string';
@@ -239,7 +215,7 @@ queryString.parse('?phoneNumber=%2B380951234567&id=1', {
239
215
  //=> {phoneNumber: '+380951234567', id: 1}
240
216
  ```
241
217
 
242
- - `'number'`: Parse `age` as a number (even when `parseNumber` is false):
218
+ - `'number'`: Parse `age` as a number (even when `parseNumbers` is false):
243
219
 
244
220
  ```js
245
221
  import queryString from 'query-string';
@@ -252,13 +228,13 @@ queryString.parse('?age=20&id=01234&zipcode=90210', {
252
228
  //=> {age: 20, id: '01234', zipcode: '90210 }
253
229
  ```
254
230
 
255
- - `'string[]'`: Parse `items` as an array of strings (overriding the `parseNumber` option):
231
+ - `'string[]'`: Parse `items` as an array of strings (overriding the `parseNumbers` option):
256
232
 
257
233
  ```js
258
234
  import queryString from 'query-string';
259
235
 
260
236
  queryString.parse('?age=20&items=1%2C2%2C3', {
261
- parseNumber: true,
237
+ parseNumbers: true,
262
238
  types: {
263
239
  items: 'string[]',
264
240
  }
@@ -266,7 +242,7 @@ queryString.parse('?age=20&items=1%2C2%2C3', {
266
242
  //=> {age: 20, items: ['1', '2', '3']}
267
243
  ```
268
244
 
269
- - `'number[]'`: Parse `items` as an array of numbers (even when `parseNumber` is false):
245
+ - `'number[]'`: Parse `items` as an array of numbers (even when `parseNumbers` is false):
270
246
 
271
247
  ```js
272
248
  import queryString from 'query-string';