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

Use new validation option to return better label

Co-authored-by: Nick O'Leary <nick.oleary@gmail.com>
This commit is contained in:
Stephen McLaughlin 2022-05-02 21:28:04 +01:00 committed by Steve-Mcl
parent a2de514c05
commit ca204dea2d

View File

@ -442,7 +442,17 @@
}
return defaultContentType || 'none'
}
/**
* Test a topic string is valid for publishing
* @param {string} topic
* @returns `true` if it is a valid topic
*/
function validateMQTTPublishTopic(topic, opts) {
if(!topic || topic == "" || !/[\+#\b\f\n\r\t\v\0]/.test(topic)) {
return true;
}
return RED._("node-red:mqtt.errors.invalid-topic");
}
RED.nodes.registerType('mqtt-broker',{
category: 'config',
defaults: {