Open lkgoerges opened 3 years ago
Getting the same problem. Will try the workaround by @lkgoerges
For those interested, I'm using this as a workaround for now.
// filename bad-words-hacked.js
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
Example code:
var Filter = require('./bad-words-hacked');
filter = new Filter();
const filteredString = filter.cleanHacked(string);
Looks like this repo is pretty much abandoned. Does anyone have a fork they plan on maintaining?
When running the
clean()
function with a string containing only emojis or symbols I receive the following error:As a workaround, I currently add "ABC" at the end of every string and remove it after the cleanup.
Example code: