query-string 8.2.0 → 9.0.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.js +11 -10
- package/package.json +7 -7
- package/readme.md +2 -1
package/base.js
CHANGED
|
@@ -5,7 +5,7 @@ import {includeKeys} from 'filter-obj';
|
|
|
5
5
|
const isNullOrUndefined = value => value === null || value === undefined;
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line unicorn/prefer-code-point
|
|
8
|
-
const strictUriEncode = string => encodeURIComponent(string).
|
|
8
|
+
const strictUriEncode = string => encodeURIComponent(string).replaceAll(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
9
9
|
|
|
10
10
|
const encodeFragmentIdentifier = Symbol('encodeFragmentIdentifier');
|
|
11
11
|
|
|
@@ -87,7 +87,7 @@ function encoderForArrayFormat(options) {
|
|
|
87
87
|
case 'comma':
|
|
88
88
|
case 'separator':
|
|
89
89
|
case 'bracket-separator': {
|
|
90
|
-
const
|
|
90
|
+
const keyValueSeparator = options.arrayFormat === 'bracket-separator'
|
|
91
91
|
? '[]='
|
|
92
92
|
: '=';
|
|
93
93
|
|
|
@@ -104,7 +104,7 @@ function encoderForArrayFormat(options) {
|
|
|
104
104
|
value = value === null ? '' : value;
|
|
105
105
|
|
|
106
106
|
if (result.length === 0) {
|
|
107
|
-
return [[encode(key, options),
|
|
107
|
+
return [[encode(key, options), keyValueSeparator, encode(value, options)].join('')];
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
|
|
@@ -353,7 +353,7 @@ export function parse(query, options) {
|
|
|
353
353
|
continue;
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
const parameter_ = options.decode ? parameter.
|
|
356
|
+
const parameter_ = options.decode ? parameter.replaceAll('+', ' ') : parameter;
|
|
357
357
|
|
|
358
358
|
let [key, value] = splitOnFirst(parameter_, '=');
|
|
359
359
|
|
|
@@ -395,10 +395,13 @@ export function stringify(object, options) {
|
|
|
395
395
|
return '';
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
options = {
|
|
398
|
+
options = {
|
|
399
|
+
encode: true,
|
|
399
400
|
strict: true,
|
|
400
401
|
arrayFormat: 'none',
|
|
401
|
-
arrayFormatSeparator: ',',
|
|
402
|
+
arrayFormatSeparator: ',',
|
|
403
|
+
...options,
|
|
404
|
+
};
|
|
402
405
|
|
|
403
406
|
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
404
407
|
|
|
@@ -484,12 +487,10 @@ export function stringifyUrl(object, options) {
|
|
|
484
487
|
};
|
|
485
488
|
|
|
486
489
|
let queryString = stringify(query, options);
|
|
487
|
-
|
|
488
|
-
queryString = `?${queryString}`;
|
|
489
|
-
}
|
|
490
|
+
queryString &&= `?${queryString}`;
|
|
490
491
|
|
|
491
492
|
let hash = getHash(object.url);
|
|
492
|
-
if (object.fragmentIdentifier) {
|
|
493
|
+
if (typeof object.fragmentIdentifier === 'string') {
|
|
493
494
|
const urlObjectForFragmentEncode = new URL(url);
|
|
494
495
|
urlObjectForFragmentEncode.hash = object.fragmentIdentifier;
|
|
495
496
|
hash = options[encodeFragmentIdentifier] ? urlObjectForFragmentEncode.hash : `#${object.fragmentIdentifier}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "query-string",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Parse and stringify URL query strings",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/query-string",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=18"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"benchmark": "node benchmark.js",
|
|
@@ -51,12 +51,12 @@
|
|
|
51
51
|
"split-on-first": "^3.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"ava": "^
|
|
54
|
+
"ava": "^6.1.1",
|
|
55
55
|
"benchmark": "^2.1.4",
|
|
56
|
-
"deep-equal": "^2.
|
|
57
|
-
"fast-check": "^3.
|
|
58
|
-
"tsd": "^0.
|
|
59
|
-
"xo": "^0.
|
|
56
|
+
"deep-equal": "^2.2.3",
|
|
57
|
+
"fast-check": "^3.15.1",
|
|
58
|
+
"tsd": "^0.30.7",
|
|
59
|
+
"xo": "^0.57.0"
|
|
60
60
|
},
|
|
61
61
|
"tsd": {
|
|
62
62
|
"compilerOptions": {
|
package/readme.md
CHANGED
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
npm install query-string
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
> [!WARNING]
|
|
48
|
+
> Remember the hyphen! Do not install the deprecated [`querystring`](https://github.com/Gozala/querystring) package!
|
|
48
49
|
|
|
49
50
|
For browser usage, this package targets the latest version of Chrome, Firefox, and Safari.
|
|
50
51
|
|