From fd60ff56bde87b3983bd4d568178f4038ce2e08e Mon Sep 17 00:00:00 2001 From: Deco Vander Date: Fri, 4 Jul 2025 14:07:51 -0400 Subject: [PATCH] Update profanity-filter.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- profanity-filter.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/profanity-filter.js b/profanity-filter.js index f6ecba3..7caf349 100644 --- a/profanity-filter.js +++ b/profanity-filter.js @@ -394,7 +394,12 @@ class ProfanityFilter { */ filterProfanity(text, replacement = '*') { const analysis = this.analyzeProfanity(text); - return analysis.filtered; + let filteredText = text; + for (const match of analysis.matches) { + const regex = new RegExp(`\\b${match.word}\\b`, 'gi'); + filteredText = filteredText.replace(regex, replacement.repeat(match.word.length)); + } + return filteredText; } /**