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

+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
));
}