query-string 9.2.0 → 9.2.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/base.d.ts +2 -1
- package/base.js +5 -1
- package/package.json +1 -1
- package/readme.md +1 -1
package/base.d.ts
CHANGED
|
@@ -286,7 +286,8 @@ export type ParseOptions = {
|
|
|
286
286
|
});
|
|
287
287
|
//=> {isAdmin: 'true', flagged: true, isOkay: false}
|
|
288
288
|
```
|
|
289
|
-
|
|
289
|
+
|
|
290
|
+
Note: The `'boolean'` type also converts `'0'` and `'1'` to booleans, and treats valueless keys (e.g. `?flag`) as `true`.
|
|
290
291
|
*/
|
|
291
292
|
readonly types?: Record<
|
|
292
293
|
string,
|
package/base.js
CHANGED
|
@@ -309,6 +309,10 @@ function parseValue(value, options, type) {
|
|
|
309
309
|
return type(value);
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
+
if (type === 'boolean' && value === null) {
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
|
|
312
316
|
if (type === 'boolean' && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
|
|
313
317
|
return value.toLowerCase() === 'true';
|
|
314
318
|
}
|
|
@@ -516,7 +520,7 @@ export function stringifyUrl(object, options) {
|
|
|
516
520
|
const queryFromUrl = extract(object.url);
|
|
517
521
|
|
|
518
522
|
const query = {
|
|
519
|
-
...parse(queryFromUrl, {sort: false}),
|
|
523
|
+
...parse(queryFromUrl, {sort: false, ...options}),
|
|
520
524
|
...object.query,
|
|
521
525
|
};
|
|
522
526
|
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -217,7 +217,7 @@ queryString.parse('?isAdmin=true&flagged=true&isOkay=0', {
|
|
|
217
217
|
//=> {isAdmin: 'true', flagged: true, isOkay: false}
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
Note: The `'boolean'` type
|
|
220
|
+
Note: The `'boolean'` type also converts `'0'` and `'1'` to booleans, and treats valueless keys (e.g. `?flag`) as `true`.
|
|
221
221
|
|
|
222
222
|
- `'string'`: Parse `phoneNumber` as a string (overriding the `parseNumbers` option):
|
|
223
223
|
|