query-string 5.1.0 → 5.1.1
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 +8 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -113,15 +113,15 @@ function keysSorter(input) {
|
|
|
113
113
|
return input;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
function extract(str) {
|
|
117
117
|
var queryStart = str.indexOf('?');
|
|
118
118
|
if (queryStart === -1) {
|
|
119
119
|
return '';
|
|
120
120
|
}
|
|
121
121
|
return str.slice(queryStart + 1);
|
|
122
|
-
}
|
|
122
|
+
}
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
function parse(str, opts) {
|
|
125
125
|
opts = objectAssign({arrayFormat: 'none'}, opts);
|
|
126
126
|
|
|
127
127
|
var formatter = parserForArrayFormat(opts);
|
|
@@ -165,7 +165,10 @@ exports.parse = function (str, opts) {
|
|
|
165
165
|
|
|
166
166
|
return result;
|
|
167
167
|
}, Object.create(null));
|
|
168
|
-
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
exports.extract = extract;
|
|
171
|
+
exports.parse = parse;
|
|
169
172
|
|
|
170
173
|
exports.stringify = function (obj, opts) {
|
|
171
174
|
var defaults = {
|
|
@@ -216,6 +219,6 @@ exports.stringify = function (obj, opts) {
|
|
|
216
219
|
exports.parseUrl = function (str, opts) {
|
|
217
220
|
return {
|
|
218
221
|
url: str.split('?')[0] || '',
|
|
219
|
-
query:
|
|
222
|
+
query: parse(extract(str), opts)
|
|
220
223
|
};
|
|
221
224
|
};
|