Skip to content

Commit

Permalink
patch(payloadEqual): escape if key is not the same on external
Browse files Browse the repository at this point in the history
  • Loading branch information
sudojunior committed Dec 4, 2022
1 parent 43a204b commit 9f7b387
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/util/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,32 @@ export function buildMessageTarget(ctx, message) {
*/
export function isPayloadEqual(source, external) {
for (const key of Object.keys(source)) {
if (['files', 'threadID', 'thread_name'].includes(key)) {
continue;
if (['files', 'threadID', 'thread_name'].includes(key)) {
continue;
}

if (Array.isArray(source[key])) {
if (source[key].length !== external[key].length) {
return false;
if (!Array.isArray(external[key])) {
return false;
}

if (source[key].length !== external[key].length) {
return false;
}

for (const [index, value] of source[key].entries()) {
if (!isPayloadEqual(value, external[key][index])) {
return false;
if (!isPayloadEqual(value, external[key][index])) {
return false;
}
}
} else if (typeof source[key] === 'object') {
if (!isPayloadEqual(source[key], external[key])) {
return false;
if (!isPayloadEqual(source[key], external[key])) {
return false;
}
} else if (source.length > 0 && source[key] !== external[key]) {
return false;
} else if (source.length > 0 && source[key] !== external[key]) {
return false;
}
}

return true;
}
}

0 comments on commit 9f7b387

Please sign in to comment.