query-string 6.1.0 → 6.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/index.js +18 -9
- package/package.json +4 -4
- package/readme.md +1 -1
package/index.js
CHANGED
|
@@ -123,6 +123,7 @@ function extract(input) {
|
|
|
123
123
|
if (queryStart === -1) {
|
|
124
124
|
return '';
|
|
125
125
|
}
|
|
126
|
+
|
|
126
127
|
return input.slice(queryStart + 1);
|
|
127
128
|
}
|
|
128
129
|
|
|
@@ -171,21 +172,24 @@ exports.extract = extract;
|
|
|
171
172
|
exports.parse = parse;
|
|
172
173
|
|
|
173
174
|
exports.stringify = (obj, options) => {
|
|
174
|
-
|
|
175
|
+
if (!obj) {
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
options = Object.assign({
|
|
175
180
|
encode: true,
|
|
176
181
|
strict: true,
|
|
177
182
|
arrayFormat: 'none'
|
|
178
|
-
};
|
|
183
|
+
}, options);
|
|
179
184
|
|
|
180
|
-
|
|
185
|
+
const formatter = encoderForArrayFormat(options);
|
|
186
|
+
const keys = Object.keys(obj);
|
|
181
187
|
|
|
182
|
-
if (options.sort
|
|
183
|
-
options.sort
|
|
188
|
+
if (options.sort !== false) {
|
|
189
|
+
keys.sort(options.sort);
|
|
184
190
|
}
|
|
185
191
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return obj ? Object.keys(obj).sort(options.sort).map(key => {
|
|
192
|
+
return keys.map(key => {
|
|
189
193
|
const value = obj[key];
|
|
190
194
|
|
|
191
195
|
if (value === undefined) {
|
|
@@ -211,10 +215,15 @@ exports.stringify = (obj, options) => {
|
|
|
211
215
|
}
|
|
212
216
|
|
|
213
217
|
return encode(key, options) + '=' + encode(value, options);
|
|
214
|
-
}).filter(x => x.length > 0).join('&')
|
|
218
|
+
}).filter(x => x.length > 0).join('&');
|
|
215
219
|
};
|
|
216
220
|
|
|
217
221
|
exports.parseUrl = (input, options) => {
|
|
222
|
+
const hashStart = input.indexOf('#');
|
|
223
|
+
if (hashStart !== -1) {
|
|
224
|
+
input = input.slice(0, hashStart);
|
|
225
|
+
}
|
|
226
|
+
|
|
218
227
|
return {
|
|
219
228
|
url: input.split('?')[0] || '',
|
|
220
229
|
query: parse(extract(input), options)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "query-string",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Parse and stringify URL query strings",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/query-string",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"strict-uri-encode": "^2.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"ava": "
|
|
41
|
+
"ava": "^0.25.0",
|
|
42
42
|
"deep-equal": "^1.0.1",
|
|
43
|
-
"fast-check": "^1.0
|
|
44
|
-
"xo": "
|
|
43
|
+
"fast-check": "^1.5.0",
|
|
44
|
+
"xo": "^0.23.0"
|
|
45
45
|
}
|
|
46
46
|
}
|
package/readme.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
$ npm install query-string
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
This module targets Node.js 6 or later and the latest version of Chrome, Firefox, and Safari. If you want support for older browsers, use version 5: `npm install query-string@5`.
|
|
18
|
+
This module targets Node.js 6 or later and the latest version of Chrome, Firefox, and Safari. If you want support for older browsers, or, [if your project is using create-react-app](https://github.com/sindresorhus/query-string/pull/148#issuecomment-399656020), use version 5: `npm install query-string@5`.
|
|
19
19
|
|
|
20
20
|
<a href="https://www.patreon.com/sindresorhus">
|
|
21
21
|
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
|