web-mech / badwords

A javascript filter for badwords
MIT License
618 stars 325 forks source link

word.toLowercase() isn't a function #52

Open SpeedyCraftah opened 5 years ago

SpeedyCraftah commented 5 years ago

Hello, when i try loading bad words from an array, i always get 'word.toLowercase() is not a function' and the words do not get added.

web-mech commented 5 years ago

Could you post an example of what you're trying to do or even better submit a failing test?

SpeedyCraftah commented 5 years ago

For example i tried running this simple code

var badw = ['foo', 'bar'] filter.addWords(badw)

And that's how I get the error. Can provide error logs if neccesary

web-mech commented 5 years ago

Take a look at the usage docs here: https://github.com/web-mech/badwords#add-words-to-the-blacklist.

There was a breaking change in the api which led to a major version upgrade. You will need to use the spread operator if you wish to use an array in this way. Adding some type checking here will prevent confusion here in the future, I have it on my list of things to do but haven't gotten around to it yet. https://github.com/web-mech/badwords/issues/49#issuecomment-450035845.

Please feel free to submit a PR if you'd like to do it yourself.