From 9eb306ab3a7c6ad183758a0e2a6ea4ad378746fc Mon Sep 17 00:00:00 2001 From: Pulse Monitor Date: Fri, 22 Aug 2025 11:06:29 +0000 Subject: [PATCH] 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. --- internal/api/config_handlers.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/api/config_handlers.go b/internal/api/config_handlers.go index 3115755a2..b3556a7bd 100644 --- a/internal/api/config_handlers.go +++ b/internal/api/config_handlers.go @@ -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" }