mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
MQTT out - Add warning if topic contains + or #
still sends msg as it causes connection to bounce which may be useful and dropping it would be a change in behaviour.
This commit is contained in:
parent
282f00e091
commit
b0c3c78899
@ -469,6 +469,7 @@ module.exports = function(RED) {
|
||||
this.broker = n.broker;
|
||||
this.brokerConn = RED.nodes.getNode(this.broker);
|
||||
var node = this;
|
||||
var chk = /[\+#]/;
|
||||
|
||||
if (this.brokerConn) {
|
||||
this.status({fill:"red",shape:"ring",text:"node-red:common.status.disconnected"});
|
||||
@ -487,6 +488,7 @@ module.exports = function(RED) {
|
||||
}
|
||||
if ( msg.hasOwnProperty("payload")) {
|
||||
if (msg.hasOwnProperty("topic") && (typeof msg.topic === "string") && (msg.topic !== "")) { // topic must exist
|
||||
if (chk.test(msg.topic)) { node.warn(RED._("mqtt.errors.invalid-topic")); }
|
||||
this.brokerConn.publish(msg, done); // send the message
|
||||
} else {
|
||||
node.warn(RED._("mqtt.errors.invalid-topic"));
|
||||
|
Loading…
Reference in New Issue
Block a user