Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bad-words

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bad-words - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

11

lib/badwords.js

@@ -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'));
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc