diff options
Diffstat (limited to 'src/plugins/apiContextMenu.ts')
-rw-r--r-- | src/plugins/apiContextMenu.ts | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/plugins/apiContextMenu.ts b/src/plugins/apiContextMenu.ts index 69dfde4..1874f5f 100644 --- a/src/plugins/apiContextMenu.ts +++ b/src/plugins/apiContextMenu.ts @@ -38,13 +38,11 @@ function listener(exports: any, id: number) { noWarn: true, find: "navId:", replacement: [{ - /** Regex explanation - * Use of https://blog.stevenlevithan.com/archives/mimic-atomic-groups to mimick atomic groups: (?=(...))\1 - * Match ${id} and look behind it for the first match of `<variable name>=`: ${id}(?=(\i)=.+?) - * Match rest of the code until it finds `<variable name>.${key},{`: .+?\2\.${key},{ - */ - match: RegExp(`(?=(${id}(?<=(\\i)=.+?).+?\\2\\.${key},{))\\1`, "g"), - replace: "$&contextMenuApiArguments:arguments," + match: RegExp(`${id}(?<=(\\i)=.+?).+$`), + replace: (code, varName) => { + const regex = RegExp(`${key},{(?<=${varName}\\.${key},{)`, "g"); + return code.replace(regex, "$&contextMenuApiArguments:arguments,"); + } }] }); |