Comparing version 1.3.1 to 1.4.1
var Filter = (function() { | ||
function Filter(options) { | ||
options = options || {}; | ||
this.list = Array.prototype.concat.apply(require('./lang.json').words, [require('badwords-list').array, options.list || []]); | ||
this.list = options.emptyList && [] || Array.prototype.concat.apply(require('./lang.json').words, [require('badwords-list').array, options.list || []]); | ||
this.placeHolder = options.placeHolder || '*'; | ||
@@ -35,2 +35,13 @@ this.regex = options.regex || /[^a-zA-z0-9|\$|\@]|\^/g; | ||
Filter.prototype.removeWords = function removeWords() { | ||
words = Array.prototype.slice.call(arguments); | ||
words.map(function(word) { | ||
return this.list.indexOf(word); | ||
}, this).filter(function(index) { | ||
return !!~index; | ||
}).forEach(function(index){ | ||
this.list.splice(index, 1); | ||
}, this); | ||
}; | ||
return Filter; | ||
@@ -37,0 +48,0 @@ })(); |
{ | ||
"name": "bad-words", | ||
"version": "1.3.1", | ||
"version": "1.4.1", | ||
"description": "A javascript filter for bad words", | ||
@@ -5,0 +5,0 @@ "main": "./lib/badwords", |
@@ -1,2 +0,2 @@ | ||
# bad-words v1.1.0 | ||
# bad-words | ||
A javascript filter for badwords | ||
@@ -46,2 +46,17 @@ | ||
### Instantiate with an empty list | ||
``` | ||
var filter = new Filter({ emptyList: true }); | ||
filter.clean('hell this wont clean anything'); //hell this wont clean anything | ||
``` | ||
### Remove words from the blacklist | ||
``` | ||
var filter = new Filter(); | ||
filter.removeWords('hells'); | ||
filter.clean("some hells word!"); //some hells word! | ||
``` | ||
## Testing | ||
@@ -52,6 +67,8 @@ ``` | ||
##Release Notes | ||
## Release Notes | ||
- v1.1.0 / Mar 17 2015: Added soundex support for comparing words to things not in the list. | ||
- v1.2.0 / May 29 2015: Removed soundex logic which resulted in many false positives within the isProfane test. | ||
- v1.3.0 / Oct 1 2015: Updated local list and documentation. Added ability to pass a custom list of words during construction. | ||
- v1.4.0 / Sept 2 2016: Added removeWords feature. Added emptyList configuration parameter. | ||
- v1.4.1 / Sept 2 2016: Updated documentation. | ||
@@ -58,0 +75,0 @@ |
@@ -24,3 +24,10 @@ require('assert'); | ||
}); | ||
it('Should allow an instance of filter with an empty blacklist', function() { | ||
var customFilter = new Filter({ | ||
emptyList: true | ||
}); | ||
assert(customFilter.clean('This is a hells good test') === 'This is a hells good test'); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16030
12
593
99