GorkemsCafe/bad-words-hacked.js
gocivici f6496327fe -fiz emoji issue
-last change before skin functionality is added
2024-02-25 12:31:29 +03:00

19 lines
592 B
JavaScript

// Emoji error fix from: https://github.com/web-mech/badwords/issues/93
const Filter = require('bad-words')
class FilterHacked extends Filter {
cleanHacked(string) {
try {
return this.clean(string);
} catch {
const joinMatch = this.splitRegex.exec(string);
const joinString = (joinMatch && joinMatch[0]) || '';
return string.split(this.splitRegex).map((word) => {
return this.isProfane(word) ? this.replaceWord(word) : word;
}).join(joinString);
}
}
}
module.exports = FilterHacked