Update profanity-filter.js
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
240f56b49d
commit
fd60ff56bd
1 changed files with 6 additions and 1 deletions
|
@ -394,7 +394,12 @@ class ProfanityFilter {
|
||||||
*/
|
*/
|
||||||
filterProfanity(text, replacement = '*') {
|
filterProfanity(text, replacement = '*') {
|
||||||
const analysis = this.analyzeProfanity(text);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue