From 54f58cd7c954a936cb833448ac0dfe027c647511 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 15 May 2024 00:38:07 -0300 Subject: [PATCH] Fix: Canonicalize regex finds --- scripts/generateReport.ts | 4 +++- src/plugins/index.ts | 7 ++++++- src/utils/patches.ts | 8 +++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index 912f38eda..164e409df 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -303,8 +303,10 @@ async function runtime(token: string) { delete patch.predicate; delete patch.group; - if (!Array.isArray(patch.replacement)) + Vencord.Util.canonicalizeFind(patch); + if (!Array.isArray(patch.replacement)) { patch.replacement = [patch.replacement]; + } patch.replacement.forEach(r => { delete r.predicate; diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 488847d15..3291885c1 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -20,6 +20,7 @@ import { registerCommand, unregisterCommand } from "@api/Commands"; import { addContextMenuPatch, removeContextMenuPatch } from "@api/ContextMenu"; import { Settings } from "@api/Settings"; import { Logger } from "@utils/Logger"; +import { canonicalizeFind } from "@utils/patches"; import { Patch, Plugin, StartAt } from "@utils/types"; import { FluxDispatcher } from "@webpack/common"; import { FluxEvents } from "@webpack/types"; @@ -83,8 +84,12 @@ for (const p of pluginsValues) { if (p.patches && isPluginEnabled(p.name)) { for (const patch of p.patches) { patch.plugin = p.name; - if (!Array.isArray(patch.replacement)) + + canonicalizeFind(patch); + if (!Array.isArray(patch.replacement)) { patch.replacement = [patch.replacement]; + } + patches.push(patch); } } diff --git a/src/utils/patches.ts b/src/utils/patches.ts index 99f0595d6..87f3ce78c 100644 --- a/src/utils/patches.ts +++ b/src/utils/patches.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { PatchReplacement, ReplaceFn } from "./types"; +import { Patch, PatchReplacement, ReplaceFn } from "./types"; export function canonicalizeMatch(match: T): T { if (typeof match === "string") return match; @@ -55,3 +55,9 @@ export function canonicalizeReplacement(replacement: Pick