From ee4df6fb500a63f898cbb2d59dded59cc44d1fba Mon Sep 17 00:00:00 2001 From: Mara-Li Date: Thu, 28 Dec 2023 23:48:11 +0100 Subject: [PATCH] refactor: adjust --- src/conversion/find_and_replace_text.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/conversion/find_and_replace_text.ts b/src/conversion/find_and_replace_text.ts index a054c582..0039aa63 100644 --- a/src/conversion/find_and_replace_text.ts +++ b/src/conversion/find_and_replace_text.ts @@ -43,15 +43,9 @@ export default function findAndReplaceText( const replaceWith = censor.replace; if (toReplace.match(/^\/.+\/[gimy]*$/)) { const regex = createRegexFromText(toReplace, censor.flags); - if (!censor.inCodeBlocks) - text = replaceText(text, regex, replaceWith, settings); - else - text = text.replace(regex, replaceWith); + text = censor.inCodeBlocks ? text.replace(regex, replaceWith) : replaceText(text, regex, replaceWith, settings); } else { - if (!censor.inCodeBlocks) - text = replaceText(text, toReplace, replaceWith, settings); - else - text = text.replace(toReplace, replaceWith); + text = censor.inCodeBlocks ? text.replace(toReplace, replaceWith) : replaceText(text, toReplace, replaceWith, settings); } } }