From cba4791b65b67fda80bba192fef766e1957b76cf Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Mon, 8 Sep 2014 20:19:25 +0100 Subject: [PATCH] MQTT node better check for topic existing --- nodes/core/io/10-mqtt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/core/io/10-mqtt.js b/nodes/core/io/10-mqtt.js index 90636500b..267a5368a 100644 --- a/nodes/core/io/10-mqtt.js +++ b/nodes/core/io/10-mqtt.js @@ -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"); }