Comparing version 0.5.0 to 0.6.0
@@ -1,5 +0,5 @@ | ||
var detector = (function() { | ||
var Filter = (function() { | ||
function Filter(options) { | ||
options = options || {}; | ||
this.list = require('./lang.json').words; | ||
this.list = Array.prototype.concat.apply( require('./lang.json').words, require('badwords-list').array ); | ||
this.placeHolder = options.placeHolder || '*'; | ||
@@ -10,10 +10,9 @@ this.Factory = Filter; | ||
Filter.prototype.isProfane = function isProfane(string) { | ||
for (var i = 0; i < this.list.length; i++) { | ||
var words = string.split(' '); | ||
for (var j = 0; j < words.length; j++) { | ||
if (words[j].toLowerCase().replace(/\*|\+|\-|\./g, '') === this.list[i].toLowerCase()) { | ||
var word = words[j].toLowerCase().replace(/\*|\+|\-|\./g, ''); | ||
if(~this.list.indexOf(word)) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
@@ -41,2 +40,2 @@ }; | ||
module.exports = new detector(); | ||
module.exports = new Filter(); |
{ | ||
"name": "bad-words", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "A javascript filter for bad words", | ||
@@ -10,3 +10,3 @@ "main": "./lib/badwords", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "./node_modules/.bin/mocha -R spec" | ||
}, | ||
@@ -23,2 +23,5 @@ "repository": { | ||
], | ||
"dependencies": { | ||
"badwords-list": "^1.0.0" | ||
}, | ||
"devDependencies":{ | ||
@@ -25,0 +28,0 @@ "mocha":"1.14.0", |
@@ -20,7 +20,6 @@ require('assert'); | ||
it('Should replace a string with proper placeholder when overridden', function(){ | ||
var customFilter = new filter.Factory({ placeHolder:'x'}); | ||
var customFilter = new filter.Factory({ placeHolder: 'x'}); | ||
assert(customFilter.clean('This is a hells good test') === 'This is a xxxxx good test'); | ||
}); | ||
}); | ||
}); |
@@ -19,3 +19,7 @@ require('assert'); | ||
}) | ||
it('Should detect filtered words from badwords-list', function(){ | ||
assert(filter.isProfane('willies')); | ||
}); | ||
}); | ||
}); |
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
13582
551
1
+ Addedbadwords-list@^1.0.0
+ Addedbadwords-list@1.0.0(transitive)