mirror of
				https://github.com/node-red/node-red-nodes.git
				synced 2025-03-01 10:37:43 +00:00 
			
		
		
		
	updated swearfilter to work with latest badwords npm (v0.3)
This commit is contained in:
		@@ -15,14 +15,14 @@
 | 
			
		||||
 **/
 | 
			
		||||
 | 
			
		||||
var RED = require(process.env.NODE_RED_HOME+"/red/red");
 | 
			
		||||
var badwords = require('badwords');
 | 
			
		||||
var badwordsRegExp = require('badwords/regexp');
 | 
			
		||||
 | 
			
		||||
function BadwordsNode(n) {
 | 
			
		||||
    RED.nodes.createNode(this,n);
 | 
			
		||||
    var node = this;
 | 
			
		||||
    this.on("input", function(msg) {
 | 
			
		||||
        if (typeof msg.payload == "string") {
 | 
			
		||||
            if (badwords.ok(msg.payload)) { node.send(msg); }
 | 
			
		||||
        if (typeof msg.payload === "string") {
 | 
			
		||||
            if ( !badwordsRegExp.test(msg.payload) ) { node.send(msg); }
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user