Update server/util-server.js

Co-authored-by: Adam Stachowicz <saibamenppl@gmail.com>
This commit is contained in:
Louis Lam 2022-01-13 11:20:32 +08:00 committed by GitHub
parent 6014ed1156
commit 482b3f9233
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -94,7 +94,7 @@ exports.mqttAsync = function (hostname, topic, okMessage, options = {}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const { port, username, password, interval = 20 } = options; const { port, username, password, interval = 20 } = options;
try { try {
// Adds mqtt protocol to the hostname if not already present // Adds MQTT protocol to the hostname if not already present
if (!/^(?:http|mqtt)s?:\/\//.test(hostname)) { if (!/^(?:http|mqtt)s?:\/\//.test(hostname)) {
hostname = "mqtt://" + hostname; hostname = "mqtt://" + hostname;
} }