From f2db050877d105fc18f85c8d8078fec79c6d48ff Mon Sep 17 00:00:00 2001 From: 7heMech <83923848+7heMech@users.noreply.github.com> Date: Sun, 13 Sep 2026 19:25:20 +0000 Subject: [PATCH] Normalize URL comparison in admin diagnostics checkDomain --- src/static/scripts/admin_diagnostics.js | 46 ++++++++++++++++++------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/static/scripts/admin_diagnostics.js b/src/static/scripts/admin_diagnostics.js index ae4d4235..f115aa9f 100644 --- a/src/static/scripts/admin_diagnostics.js +++ b/src/static/scripts/admin_diagnostics.js @@ -195,19 +195,41 @@ function checkTimeDrift(utcTimeA, utcTimeB, statusPrefix) { } function checkDomain(browserURL, serverURL) { - if (serverURL == browserURL) { - document.getElementById("domain-success").classList.remove("d-none"); - domainCheck = true; - } else { - document.getElementById("domain-warning").classList.remove("d-none"); - } + try { + const browser = new URL(browserURL); + const server = new URL(serverURL); - // Check for HTTPS at domain-server-string - if (serverURL.startsWith("https://") ) { - document.getElementById("https-success").classList.remove("d-none"); - httpsCheck = true; - } else { - document.getElementById("https-warning").classList.remove("d-none"); + const browserPath = browser.pathname.split("/").filter(Boolean).join("/"); + const serverPath = server.pathname.split("/").filter(Boolean).join("/"); + + if (browser.origin === server.origin && browserPath === serverPath) { + document.getElementById("domain-success").classList.remove("d-none"); + domainCheck = true; + } else { + document.getElementById("domain-warning").classList.remove("d-none"); + } + + // Check for HTTPS at domain-server-string + if (server.protocol === "https:") { + document.getElementById("https-success").classList.remove("d-none"); + httpsCheck = true; + } else { + document.getElementById("https-warning").classList.remove("d-none"); + } + } catch { + if (serverURL == browserURL) { + document.getElementById("domain-success").classList.remove("d-none"); + domainCheck = true; + } else { + document.getElementById("domain-warning").classList.remove("d-none"); + } + + if (serverURL.startsWith("https://")) { + document.getElementById("https-success").classList.remove("d-none"); + httpsCheck = true; + } else { + document.getElementById("https-warning").classList.remove("d-none"); + } } }