TextReplace: allow replacing with nothing (#1933)

This commit is contained in:
effct • Lia Aaron Thoma 2024-01-06 01:02:09 +01:00 committed by GitHub
parent d5c58ab2b3
commit 0d6bb35075
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -213,7 +213,7 @@ function applyRules(content: string): string {
if (stringRules) {
for (const rule of stringRules) {
if (!rule.find || !rule.replace) continue;
if (!rule.find) continue;
if (rule.onlyIfIncludes && !content.includes(rule.onlyIfIncludes)) continue;
content = ` ${content} `.replaceAll(rule.find, rule.replace.replaceAll("\\n", "\n")).replace(/^\s|\s$/g, "");
@ -222,7 +222,7 @@ function applyRules(content: string): string {
if (regexRules) {
for (const rule of regexRules) {
if (!rule.find || !rule.replace) continue;
if (!rule.find) continue;
if (rule.onlyIfIncludes && !content.includes(rule.onlyIfIncludes)) continue;
try {