MQTT node better check for topic existing

This commit is contained in:
Dave C-J 2014-09-08 20:19:25 +01:00
parent ab4d3c025e
commit cba4791b65

View File

@ -95,7 +95,7 @@ module.exports = function(RED) {
if (node.topic) {
msg.topic = node.topic;
}
if (typeof msg.topic === "string") { // topic must be a string
if ((msg.hasOwnProperty("topic")) && (typeof msg.topic === "string") && (msg.topic !== "")) { // topic must exist
this.client.publish(msg); // send the message
}
else { node.warn("Invalid topic specified"); }