badwords icon indicating copy to clipboard operation
badwords copied to clipboard

word.toLowercase() isn't a function

Open SpeedyCraftah opened this issue 6 years ago • 3 comments

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.

SpeedyCraftah avatar Apr 16 '19 10:04 SpeedyCraftah

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

web-mech avatar Apr 22 '19 14:04 web-mech

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

SpeedyCraftah avatar Apr 22 '19 22:04 SpeedyCraftah

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.

web-mech avatar Apr 23 '19 17:04 web-mech