Update profanity-filter.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Deco Vander 2025-07-04 14:07:51 -04:00 committed by GitHub
parent 240f56b49d
commit fd60ff56bd

View file

@ -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;
}
/**