Skip to content

Commit c41a546

Browse files
author
Johan Bengtsson
committed
Allow different external swear word files
Added Local Storage key that differs between different extternal swears word files by using different keys
1 parent f91d526 commit c41a546

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

jquery.profanityfilter.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,16 @@
129129
x,
130130
inputs = $(this).find(':input'),
131131
profane = false,
132-
data = [];
132+
data = [],
133+
localSwearsKey = 'localSwears' + options.externalSwears;
133134

134135
if (options.externalSwears !== null) {
135136
if (localStorageIsEnabled) {
136-
if (localStorage.getItem('localSwears') === null) {
137+
if (localStorage.getItem(localSwearsKey) === null) {
137138
// stringify the array so that it can be stored in local storage
138-
localStorage.setItem('localSwears', JSON.stringify(readJsonFromController(options.externalSwears)));
139+
localStorage.setItem(localSwearsKey, JSON.stringify(readJsonFromController(options.externalSwears)));
139140
}
140-
badWords = JSON.parse(localStorage.getItem('localSwears'));
141+
badWords = JSON.parse(localStorage.getItem(localSwearsKey));
141142
} else {
142143
badWords = readJsonFromController(options.externalSwears);
143144
}
@@ -194,4 +195,4 @@
194195
};
195196
});
196197
};
197-
})(jQuery);
198+
})(jQuery);

0 commit comments

Comments
 (0)