aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAutumnVN <autumnvnchino@gmail.com>2023-09-19 09:09:37 +0700
committerV <vendicated@riseup.net>2023-09-19 04:11:30 +0200
commit1f87d14ab2098e80da00b646b19f3892129252d2 (patch)
treebf32f750535da9f9d0430ac25dc46ff06806e066 /src
parent7d8f3508a8dc8754264d3163d79b22041c051d1d (diff)
downloadVencord-1f87d14ab2098e80da00b646b19f3892129252d2.tar.gz
Vencord-1f87d14ab2098e80da00b646b19f3892129252d2.tar.bz2
Vencord-1f87d14ab2098e80da00b646b19f3892129252d2.zip
textReplace: pad space only in string rules (#1738)
Diffstat (limited to 'src')
-rw-r--r--src/plugins/textReplace.tsx5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/plugins/textReplace.tsx b/src/plugins/textReplace.tsx
index 1e8aca7..45fb6f9 100644
--- a/src/plugins/textReplace.tsx
+++ b/src/plugins/textReplace.tsx
@@ -213,15 +213,12 @@ function applyRules(content: string): string {
if (content.length === 0)
return content;
- // pad so that rules can use " word " to only match whole "word"
- content = " " + content + " ";
-
if (stringRules) {
for (const rule of stringRules) {
if (!rule.find || !rule.replace) continue;
if (rule.onlyIfIncludes && !content.includes(rule.onlyIfIncludes)) continue;
- content = content.replaceAll(rule.find, rule.replace.replaceAll("\\n", "\n"));
+ content = ` ${content} `.replaceAll(rule.find, rule.replace.replaceAll("\\n", "\n")).replace(/^\s|\s$/g, "");
}
}