mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Use new validation option to return better label
Co-authored-by: Nick O'Leary <nick.oleary@gmail.com>
This commit is contained in:
		
				
					committed by
					
						
						Steve-Mcl
					
				
			
			
				
	
			
			
			
						parent
						
							a2de514c05
						
					
				
				
					commit
					ca204dea2d
				
			@@ -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: {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user