badwords
badwords copied to clipboard
Bug: won't find word with dash/hyphen profane
Given the example below:
const BadWords = require('bad-words');
const bw = new BadWords()
bw.addWords(['foo-bar', 'foobar'])
> bw.isProfane('foobar')
'foobar'
> bw.isProfane('foo-bar')
false
I would expect bw.isProfine('foo-bar')
to return "foo-bar"
and not false
.
I am pretty sure you add words in arguments and not array, like bw.addWords('foo-bar', 'foobar')
and when I did that both returned true, which from documentation is the expected result
The same happens with underscores
const filter = new Filter({ list: ['some', 'bad', 'word'] });
[
filter.isProfane("some bad word"),
filter.isProfane("some_bad_word")
]
// [ true, false ]
The library is only meant to check between word boundaries, so I would not say it is a bug.
Then maybe this should be a feature request... its also a problem with words merged together with no boundary.
const filter = new Filter({ list: ['some', 'bad', 'word'] });
[
filter.isProfane("some bad word"),
filter.isProfane("somebadword")
]
// [ true, false ]
When really offensive words are used like this, it doesn't matter if there are spaces, its still offensive and should be considered profane...