Skip to content

Commit 07e303b

Browse files
committed
Remove anything behind .local and ignore case
1 parent 24f2306 commit 07e303b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

wled00/mqtt.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ bool initMqtt()
215215
} else {
216216
#ifdef ARDUINO_ARCH_ESP32
217217
String mqttMDNS = mqttServer;
218-
mqttMDNS.replace(F(".local"), ""); // remove .local if present
218+
mqttMDNS.toLowerCase(); // make sure we have a lowercase hostname
219+
int pos = mqttMDNS.indexOf(F(".local"));
220+
if (pos > 0) mqttMDNS.remove(pos); // remove .local domain if present (and anything following it)
219221
if (strlen(cmDNS) > 0 && mqttMDNS.length() > 0 && mqttMDNS.indexOf('.') < 0) { // if mDNS is enabled and server does not have domain
220222
mqttIP = MDNS.queryHost(mqttMDNS.c_str());
221223
if (mqttIP != IPAddress()) // if MDNS resolved the hostname

0 commit comments

Comments
 (0)