Merge pull request #4416 from node-red/mqtt-check-topic-length

check topic length > 0 before publish
This commit is contained in:
Nick O'Leary
2023-11-07 17:46:33 +00:00
committed by GitHub

View File

@@ -104,6 +104,7 @@ module.exports = function(RED) {
* @returns `true` if it is a valid topic * @returns `true` if it is a valid topic
*/ */
function isValidPublishTopic(topic) { function isValidPublishTopic(topic) {
if (topic.length === 0) return false;
return !/[\+#\b\f\n\r\t\v\0]/.test(topic); return !/[\+#\b\f\n\r\t\v\0]/.test(topic);
} }