Closed Grayy12 closed 2 days ago
const { Profanity, CensorType } = require("@2toad/profanity");
const profanity = new Profanity({
languages: ["en"],
wholeWord: true,
grawlix: "****",
});
profanity.removeWords(["damn"]);
console.log(profanity.censor("damn", CensorType.Word));
I may be using the whitelist wrong, but if I just remove the word, it works.
Thanks for submitting this issue @Grayy12. I'll take a look
Able to reproduce. Working on a fix
Thank you!
Fixed in v3.0.1
const { Profanity, CensorType } = require("@2toad/profanity");
const profanity = new Profanity({
languages: ["en"],
wholeWord: true,
grawlix: "****",
});
// Damn should be replaced with "****"
console.log(profanity.censor("damn", CensorType.Word));
console.log(profanity.censor("This is damn good!", CensorType.Word));
/* Output
----------------------
****
This is **** good!
----------------------
*/
// Damn should not be replaced
profanity.whitelist.addWords(["damn"]);
console.log(profanity.censor("damn", CensorType.Word));
console.log(profanity.censor("This is damn good!", CensorType.Word));
/* Output
----------------------
damn
This is damn good!
----------------------
*/
Damn is still censored even though I added it to the whitelist.