fix: correct key handling in revertEscape function for arrays and objects

This commit is contained in:
Sheldon Guo 2025-03-02 12:23:58 +08:00
parent 553688f316
commit 5d641bd123

View File

@ -47,10 +47,12 @@ export function revertEscape(input) {
if (isArray(input)) { if (isArray(input)) {
const result = []; const result = [];
Object.keys(input).forEach((key) => { Object.keys(input).forEach((key) => {
result[escape(key)] = revertEscape(input[key]); result[revertEscape(key)] = revertEscape(input[key]);
}); });
return input.map(revertEscape); return result;
} else if (isObject(input)) {
// check keys number of object to skip the object like new Date()
} else if (isObject(input && Object.keys(input).length > 0)) {
return mapKeys(mapValues(input, revertEscape), (value, key) => revertEscape(key)); return mapKeys(mapValues(input, revertEscape), (value, key) => revertEscape(key));
} else if (isString(input)) { } else if (isString(input)) {
return revertEscapeSpecialChars(input); return revertEscapeSpecialChars(input);