fix: address PBS custom port handling issue #346

PBS was incorrectly appending default port :8007 even when custom ports were specified, resulting in malformed URLs like domain:443:8007. Now properly detects existing ports after the protocol prefix.
This commit is contained in:
Pulse Monitor
2025-08-22 11:06:29 +00:00
parent 12f79e77d4
commit 9eb306ab3a
+9 -1
View File
@@ -392,7 +392,15 @@ func (h *ConfigHandlers) HandleAddNode(w http.ResponseWriter, r *http.Request) {
host = "https://" + host
}
// Add default PBS port if missing
if !strings.Contains(host, ":8007") && !strings.Contains(host[8:], ":") {
// Check if there's no port specified after the protocol
protocolEnd := 0
if strings.HasPrefix(host, "https://") {
protocolEnd = 8
} else if strings.HasPrefix(host, "http://") {
protocolEnd = 7
}
// Only add default port if no port is specified
if protocolEnd > 0 && !strings.Contains(host[protocolEnd:], ":") {
host = host + ":8007"
}