Check node.broker is a string before trying to use it

Fixes #4380
This commit is contained in:
Nick O'Leary 2023-11-27 17:27:32 +00:00
parent a55554193b
commit 9c71d52d69
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -612,7 +612,7 @@ module.exports = function(RED) {
node.brokerurl = node.url;
} else {
// if the broker is ws:// or wss:// or tcp://
if (node.broker.indexOf("://") > -1) {
if ((typeof node.broker === 'string') && node.broker.indexOf("://") > -1) {
node.brokerurl = node.broker;
// Only for ws or wss, check if proxy env var for additional configuration
if (node.brokerurl.indexOf("wss://") > -1 || node.brokerurl.indexOf("ws://") > -1) {