query-string 8.0.3 → 8.2.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/base.d.ts +2 -2
- package/base.js +13 -9
- package/package.json +5 -4
- package/readme.md +1 -1
package/base.d.ts
CHANGED
|
@@ -220,7 +220,7 @@ export function parseUrl(url: string, options?: ParseOptions): ParsedUrl;
|
|
|
220
220
|
|
|
221
221
|
export type StringifyOptions = {
|
|
222
222
|
/**
|
|
223
|
-
Strictly encode URI components
|
|
223
|
+
Strictly encode URI components. It uses [`encodeURIComponent`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) if set to `false`. You probably [don't care](https://github.com/sindresorhus/query-string/issues/42) about this option.
|
|
224
224
|
|
|
225
225
|
@default true
|
|
226
226
|
*/
|
|
@@ -412,7 +412,7 @@ export type StringifyOptions = {
|
|
|
412
412
|
readonly skipEmptyString?: boolean;
|
|
413
413
|
};
|
|
414
414
|
|
|
415
|
-
export type Stringifiable = string | boolean | number | null | undefined; // eslint-disable-line @typescript-eslint/ban-types
|
|
415
|
+
export type Stringifiable = string | boolean | number | bigint | null | undefined; // eslint-disable-line @typescript-eslint/ban-types
|
|
416
416
|
|
|
417
417
|
export type StringifiableRecord = Record<
|
|
418
418
|
string,
|
package/base.js
CHANGED
|
@@ -353,7 +353,13 @@ export function parse(query, options) {
|
|
|
353
353
|
continue;
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
|
|
356
|
+
const parameter_ = options.decode ? parameter.replace(/\+/g, ' ') : parameter;
|
|
357
|
+
|
|
358
|
+
let [key, value] = splitOnFirst(parameter_, '=');
|
|
359
|
+
|
|
360
|
+
if (key === undefined) {
|
|
361
|
+
key = parameter_;
|
|
362
|
+
}
|
|
357
363
|
|
|
358
364
|
// Missing `=` should be `null`:
|
|
359
365
|
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
|
|
@@ -379,13 +385,7 @@ export function parse(query, options) {
|
|
|
379
385
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
380
386
|
return (options.sort === true ? Object.keys(returnValue).sort() : Object.keys(returnValue).sort(options.sort)).reduce((result, key) => {
|
|
381
387
|
const value = returnValue[key];
|
|
382
|
-
|
|
383
|
-
// Sort object keys, not values
|
|
384
|
-
result[key] = keysSorter(value);
|
|
385
|
-
} else {
|
|
386
|
-
result[key] = value;
|
|
387
|
-
}
|
|
388
|
-
|
|
388
|
+
result[key] = Boolean(value) && typeof value === 'object' && !Array.isArray(value) ? keysSorter(value) : value;
|
|
389
389
|
return result;
|
|
390
390
|
}, Object.create(null));
|
|
391
391
|
}
|
|
@@ -454,7 +454,11 @@ export function parseUrl(url, options) {
|
|
|
454
454
|
...options,
|
|
455
455
|
};
|
|
456
456
|
|
|
457
|
-
|
|
457
|
+
let [url_, hash] = splitOnFirst(url, '#');
|
|
458
|
+
|
|
459
|
+
if (url_ === undefined) {
|
|
460
|
+
url_ = url;
|
|
461
|
+
}
|
|
458
462
|
|
|
459
463
|
return {
|
|
460
464
|
url: url_?.split('?')?.[0] ?? '',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "query-string",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "Parse and stringify URL query strings",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/query-string",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"types": "./index.d.ts",
|
|
16
16
|
"default": "./index.js"
|
|
17
17
|
},
|
|
18
|
+
"sideEffects": false,
|
|
18
19
|
"engines": {
|
|
19
20
|
"node": ">=14.16"
|
|
20
21
|
},
|
|
@@ -45,9 +46,9 @@
|
|
|
45
46
|
"filter"
|
|
46
47
|
],
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"decode-uri-component": "^0.
|
|
49
|
+
"decode-uri-component": "^0.4.1",
|
|
49
50
|
"filter-obj": "^5.1.0",
|
|
50
|
-
"split-on-first": "^
|
|
51
|
+
"split-on-first": "^3.0.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"ava": "^5.1.0",
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
"deep-equal": "^2.1.0",
|
|
56
57
|
"fast-check": "^3.4.0",
|
|
57
58
|
"tsd": "^0.25.0",
|
|
58
|
-
"xo": "^0.
|
|
59
|
+
"xo": "^0.54.2"
|
|
59
60
|
},
|
|
60
61
|
"tsd": {
|
|
61
62
|
"compilerOptions": {
|
package/readme.md
CHANGED
|
@@ -236,7 +236,7 @@ Type: `object`
|
|
|
236
236
|
Type: `boolean`\
|
|
237
237
|
Default: `true`
|
|
238
238
|
|
|
239
|
-
Strictly encode URI components
|
|
239
|
+
Strictly encode URI components. It uses [encodeURIComponent](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) if set to false. You probably [don't care](https://github.com/sindresorhus/query-string/issues/42) about this option.
|
|
240
240
|
|
|
241
241
|
##### encode
|
|
242
242
|
|