1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Handle invalid property values in Switch node

Fixes #404
This commit is contained in:
Nick O'Leary 2014-09-17 22:31:26 +01:00
parent f04e42e4da
commit ebb0d1a46d

View File

@ -38,8 +38,8 @@ module.exports = function(RED) {
this.rules = n.rules;
this.property = n.property;
this.checkall = n.checkall || "true";
var propertyParts = n.property.split("."),
node = this;
var propertyParts = n.property.split(".");
var node = this;
for (var i=0; i<this.rules.length; i+=1) {
var rule = this.rules[i];
@ -51,6 +51,7 @@ module.exports = function(RED) {
this.on('input', function (msg) {
var onward = [];
try {
var prop = propertyParts.reduce(function (obj, i) {
return obj[i]
}, msg);
@ -68,6 +69,9 @@ module.exports = function(RED) {
}
}
this.send(onward);
} catch(err) {
node.warn(err);
}
});
}
RED.nodes.registerType("switch", SwitchNode);