Skip to content

Commit

Permalink
how on earth did this not get caught as an error wth
Browse files Browse the repository at this point in the history
  • Loading branch information
RedMan13 committed Aug 17, 2024
1 parent 99b09fe commit d86a78c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/compiler/jsexecute.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,13 +612,13 @@ runtimeFunctions.parseJSONSafe = `const parseJSONSafe = json => {
}`;

runtimeFunctions._resolveKeyPath = `const _resolveKeyPath = (obj, keyPath) => {
const path = keyPath.matchAll(/(\\.|^)(?<key>[^.[]+)|\\[(?<litkey>(\\\\\\]|[^]])+)\\]/g);
const path = keyPath.matchAll(/(\\.|^)(?<key>[^.[]+)|\\[(?<litkey>(\\\\\\]|\\\\|[^]])+)\\]/g);
let top = obj;
let pre;
let tok;
let key;
while (!(tok = path.next()).done) {
key = tok.value.groups.key ?? tok.value.groups.litKey;
key = tok.value.groups.key ?? tok.value.groups.litKey.replaceAll('\\\\', '\\').replaceAll('\\\\]', ']');
pre = top;
top = top?.get?.(key) ?? top?.[key];
if (!top) return [obj, keyPath];
Expand Down Expand Up @@ -673,6 +673,9 @@ const insertRuntime = source => {
if (result.includes('executeInCompatibilityLayer') && !result.includes('const waitPromise')) {
result = result.replace('let hasResumedFromPromise = false;', `let hasResumedFromPromise = false;\n${runtimeFunctions.waitPromise}`);
}
if (result.includes('_resolveKeyPath') && !result.includes('const _resolveKeyPath')) {
result = runtimeFunctions._resolveKeyPath + ';' + result;
}
result += `return ${source}`;
return result;
};
Expand Down

0 comments on commit d86a78c

Please sign in to comment.