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
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
<script type="text/x-red" data-help-name="badwords">
|
<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>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -42,5 +43,4 @@
|
|||||||
return this.name?"node_label_italic":"";
|
return this.name?"node_label_italic":"";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -14,15 +14,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
var RED = require("../../red/red");
|
||||||
var badwords = require('badwords');
|
var badwords = require('badwords');
|
||||||
|
|
||||||
function BadwordsNode(n) {
|
function BadwordsNode(n) {
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
var node = this;
|
var node = this;
|
||||||
this.on("input", function(msg) {
|
this.on("input", function(msg) {
|
||||||
|
if (typeof msg.payload == "string") {
|
||||||
if (badwords.ok(msg.payload)) { node.send(msg); }
|
if (badwords.ok(msg.payload)) { node.send(msg); }
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType("badwords",BadwordsNode);
|
RED.nodes.registerType("badwords",BadwordsNode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user