Update checked-in dependencies
This commit is contained in:
parent
5a7f86f625
commit
9c0cd50e9e
5 changed files with 221 additions and 15 deletions
55
node_modules/query-string/index.js
generated
vendored
55
node_modules/query-string/index.js
generated
vendored
|
|
@ -6,6 +6,8 @@ const filterObject = require('filter-obj');
|
|||
|
||||
const isNullOrUndefined = value => value === null || value === undefined;
|
||||
|
||||
const encodeFragmentIdentifier = Symbol('encodeFragmentIdentifier');
|
||||
|
||||
function encoderForArrayFormat(options) {
|
||||
switch (options.arrayFormat) {
|
||||
case 'index':
|
||||
|
|
@ -49,17 +51,30 @@ function encoderForArrayFormat(options) {
|
|||
|
||||
case 'comma':
|
||||
case 'separator':
|
||||
case 'bracket-separator': {
|
||||
const keyValueSep = options.arrayFormat === 'bracket-separator' ?
|
||||
'[]=' :
|
||||
'=';
|
||||
|
||||
return key => (result, value) => {
|
||||
if (value === null || value === undefined || value.length === 0) {
|
||||
if (
|
||||
value === undefined ||
|
||||
(options.skipNull && value === null) ||
|
||||
(options.skipEmptyString && value === '')
|
||||
) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Translate null to an empty string so that it doesn't serialize as 'null'
|
||||
value = value === null ? '' : value;
|
||||
|
||||
if (result.length === 0) {
|
||||
return [[encode(key, options), '=', encode(value, options)].join('')];
|
||||
return [[encode(key, options), keyValueSep, encode(value, options)].join('')];
|
||||
}
|
||||
|
||||
return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
return key => (result, value) => {
|
||||
|
|
@ -130,6 +145,28 @@ function parserForArrayFormat(options) {
|
|||
accumulator[key] = newValue;
|
||||
};
|
||||
|
||||
case 'bracket-separator':
|
||||
return (key, value, accumulator) => {
|
||||
const isArray = /(\[\])$/.test(key);
|
||||
key = key.replace(/\[\]$/, '');
|
||||
|
||||
if (!isArray) {
|
||||
accumulator[key] = value ? decode(value, options) : value;
|
||||
return;
|
||||
}
|
||||
|
||||
const arrayValue = value === null ?
|
||||
[] :
|
||||
value.split(options.arrayFormatSeparator).map(item => decode(item, options));
|
||||
|
||||
if (accumulator[key] === undefined) {
|
||||
accumulator[key] = arrayValue;
|
||||
return;
|
||||
}
|
||||
|
||||
accumulator[key] = [].concat(accumulator[key], arrayValue);
|
||||
};
|
||||
|
||||
default:
|
||||
return (key, value, accumulator) => {
|
||||
if (accumulator[key] === undefined) {
|
||||
|
|
@ -253,7 +290,7 @@ function parse(query, options) {
|
|||
|
||||
// Missing `=` should be `null`:
|
||||
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
|
||||
value = value === undefined ? null : ['comma', 'separator'].includes(options.arrayFormat) ? value : decode(value, options);
|
||||
value = value === undefined ? null : ['comma', 'separator', 'bracket-separator'].includes(options.arrayFormat) ? value : decode(value, options);
|
||||
formatter(decode(key, options), value, ret);
|
||||
}
|
||||
|
||||
|
|
@ -335,6 +372,10 @@ exports.stringify = (object, options) => {
|
|||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
if (value.length === 0 && options.arrayFormat === 'bracket-separator') {
|
||||
return encode(key, options) + '[]';
|
||||
}
|
||||
|
||||
return value
|
||||
.reduce(formatter(key), [])
|
||||
.join('&');
|
||||
|
|
@ -363,7 +404,8 @@ exports.parseUrl = (url, options) => {
|
|||
exports.stringifyUrl = (object, options) => {
|
||||
options = Object.assign({
|
||||
encode: true,
|
||||
strict: true
|
||||
strict: true,
|
||||
[encodeFragmentIdentifier]: true
|
||||
}, options);
|
||||
|
||||
const url = removeHash(object.url).split('?')[0] || '';
|
||||
|
|
@ -378,7 +420,7 @@ exports.stringifyUrl = (object, options) => {
|
|||
|
||||
let hash = getHash(object.url);
|
||||
if (object.fragmentIdentifier) {
|
||||
hash = `#${encode(object.fragmentIdentifier, options)}`;
|
||||
hash = `#${options[encodeFragmentIdentifier] ? encode(object.fragmentIdentifier, options) : object.fragmentIdentifier}`;
|
||||
}
|
||||
|
||||
return `${url}${queryString}${hash}`;
|
||||
|
|
@ -386,7 +428,8 @@ exports.stringifyUrl = (object, options) => {
|
|||
|
||||
exports.pick = (input, filter, options) => {
|
||||
options = Object.assign({
|
||||
parseFragmentIdentifier: true
|
||||
parseFragmentIdentifier: true,
|
||||
[encodeFragmentIdentifier]: false
|
||||
}, options);
|
||||
|
||||
const {url, query, fragmentIdentifier} = exports.parseUrl(input, options);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue