mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Make bad word filter only operate on strings - drop anything else.
This commit is contained in:
parent
28e82c1351
commit
6425bd75cb
@ -22,7 +22,8 @@
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="badwords">
|
||||
<p>Analyses the <b>msg.payload</b> and tries to filter out any messages containing bad swear words...</p>
|
||||
<p>Analyses the <b>msg.payload</b> and tries to filter out any messages containing bad swear words...</p>
|
||||
<p><b>Note:</b> this only operates on payloads of type <b>string</b>. Everything else is blocked.</p>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
@ -42,5 +43,4 @@
|
||||
return this.name?"node_label_italic":"";
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
@ -14,15 +14,16 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
||||
var RED = require("../../red/red");
|
||||
var badwords = require('badwords');
|
||||
|
||||
function BadwordsNode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
var node = this;
|
||||
this.on("input", function(msg) {
|
||||
if (badwords.ok(msg.payload)) { node.send(msg); }
|
||||
if (typeof msg.payload == "string") {
|
||||
if (badwords.ok(msg.payload)) { node.send(msg); }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
RED.nodes.registerType("badwords",BadwordsNode);
|
||||
|
Loading…
Reference in New Issue
Block a user