alle new
This commit is contained in:
erik committed 2026-10-01 06:46:51 +02:00
1 parent da64472251
commit 5b20adee48
1605 files changed
+396517 -1674

No files matched your search

+3 -4
View File
@@ -36,9 +36,9 @@ var interpretNumericEntities = function (str) {
});
};
var parseArrayValue = function (val, options, currentArrayLength, isFlatArrayValue) {
var parseArrayValue = function (val, options, currentArrayLength) {
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
if (isFlatArrayValue && options.throwOnLimitExceeded) {
if (options.throwOnLimitExceeded) {
var commaCount = 0;
var commaIndex = val.indexOf(',');
while (commaIndex > -1) {
@@ -125,8 +125,7 @@ var parseValues = function parseQueryStringValues(str, options) {
parseArrayValue(
part.slice(pos + 1),
options,
isArray(obj[key]) ? obj[key].length : 0,
part.indexOf('[]=') === -1
isArray(obj[key]) ? obj[key].length : 0
),
function (encodedVal) {
return options.decoder(encodedVal, defaults.decoder, charset, 'value');
+23 -8
View File
@@ -36,6 +36,7 @@ var defaults = {
charsetSentinel: false,
commaRoundTrip: false,
delimiter: '&',
depth: Infinity,
encode: true,
encodeDotInKeys: false,
encoder: utils.encode,
@@ -80,10 +81,16 @@ var stringify = function stringify(
formatter,
encodeValuesOnly,
charset,
sideChannel
sideChannel,
depth,
currentDepth
) {
var obj = object;
if (currentDepth > depth) {
throw new RangeError('Input depth exceeded depth option of ' + depth);
}
var tmpSc = sideChannel;
var step = 0;
var findFlag = false;
@@ -103,9 +110,9 @@ var stringify = function stringify(
}
}
if (typeof filter === 'function') {
obj = filter(prefix, obj);
} else if (obj instanceof Date) {
obj = typeof filter === 'function' ? filter(prefix, obj) : obj;
if (obj instanceof Date) {
obj = serializeDate(obj);
} else if (generateArrayPrefix === 'comma' && isArray(obj)) {
obj = utils.maybeMap(obj, function (value) {
@@ -158,7 +165,7 @@ var stringify = function stringify(
var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? encodedPrefix + '[]' : encodedPrefix;
if (allowEmptyArrays && isArray(obj) && obj.length === 0) {
if (allowEmptyArrays && isArray(obj) && obj.length === 0 && Object.keys(obj).length === 0) {
return adjustedPrefix + '[]';
}
@@ -198,7 +205,9 @@ var stringify = function stringify(
formatter,
encodeValuesOnly,
charset,
valueSideChannel
valueSideChannel,
depth,
currentDepth + 1
));
}
@@ -265,6 +274,7 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
commaRoundTrip: !!opts.commaRoundTrip,
delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
depth: typeof opts.depth === 'number' ? opts.depth : defaults.depth,
encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
encodeDotInKeys: typeof opts.encodeDotInKeys === 'boolean' ? opts.encodeDotInKeys : defaults.encodeDotInKeys,
encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
@@ -324,9 +334,12 @@ module.exports = function (object, opts) {
if (options.skipNulls && value === null) {
continue;
}
var encodedKey = options.encodeDotInKeys ? String(key).replace(/\./g, '%2E') : String(key);
pushToArray(keys, stringify(
value,
key,
encodedKey,
generateArrayPrefix,
commaRoundTrip,
options.allowEmptyArrays,
@@ -342,7 +355,9 @@ module.exports = function (object, opts) {
options.formatter,
options.encodeValuesOnly,
options.charset,
sideChannel
sideChannel,
options.depth,
0
));
}
+10 -3
View File
@@ -329,7 +329,7 @@ var isBuffer = function isBuffer(obj) {
return false;
}
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
return !!(obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj));
};
var combine = function combine(a, b, arrayLimit, plainObjects, throwOnLimitExceeded) {
@@ -338,8 +338,15 @@ var combine = function combine(a, b, arrayLimit, plainObjects, throwOnLimitExcee
if (throwOnLimitExceeded) {
throw new RangeError('Array limit exceeded. Only ' + arrayLimit + ' element' + (arrayLimit === 1 ? '' : 's') + ' allowed in an array.');
}
var newIndex = getMaxIndex(a) + 1;
a[newIndex] = b;
// spread `b` one level, matching the `[].concat(a, b)` used below, so a
// collection appended to an already-overflowed object is flattened
// rather than nested under a single index
var bValues = isArray(b) ? b : [b];
var newIndex = getMaxIndex(a);
for (var i = 0; i < bValues.length; ++i) {
newIndex += 1;
a[newIndex] = bValues[i];
}
setMaxIndex(a, newIndex);
return a;
}