-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Using the latest version of your demo code, plus the existing swearWords.json file, the browser produces an error message as follows:
Uncaught TypeError: badWords.concat(...).unique is not a function
at HTMLDivElement. (jquery.profanityfilter.js:148)
at Function.each (jquery.min.js:2)
at init.each (jquery.min.js:2)
at init.$.fn.profanityFilter (jquery.profanityfilter.js:122)
at profanity-original-demo.html:146
From what I can tell, the issue lies with this line:
var badWordsJSON = localStorage.getItem(localSwearsKey);
Where the results come back as """" (two actual quotes inside of a quoted string). This causes the next line to fail:
if (badWordsJSON === null) {
... because it really isn't null, it's a set of actual quotes. Changing the line to:
if (badWordsJSON === null || badWordsJSON == "\"\"") {
fixes the problem.
Thank you!