From 1dd395fdd6602e4c700fbdc535d92fe67016355e Mon Sep 17 00:00:00 2001 From: Johngenri Date: Sun, 8 Mar 2026 16:01:26 +0100 Subject: [PATCH] fix: ignore cross-origin basename hints --- src/App.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 0371cd70..285d25d4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -38,7 +38,12 @@ function detectRouterBasename() { let detectedBasename = ''; for (const candidate of candidatePaths) { try { - const pathname = new URL(candidate.value, document.baseURI || window.location.href).pathname; + const candidateUrl = new URL(candidate.value, document.baseURI || window.location.href); + if (candidateUrl.origin !== window.location.origin) { + continue; + } + + const pathname = candidateUrl.pathname; const normalizedPathname = pathname.replace(/\/+$/, ''); let normalized = ''; @@ -53,7 +58,7 @@ function detectRouterBasename() { const match = candidate.kind === 'manifest' ? manifestMatch : iconMatch; if (match?.[1]) { const segments = match[1].split('/').filter(Boolean); - while (segments.length > 0 && ['assets', 'static', 'icons', 'images'].includes(segments[segments.length - 1])) { + while (segments.length > 1 && ['assets', 'static', 'icons', 'images'].includes(segments[segments.length - 1])) { segments.pop(); } normalized = segments.length > 0 ? `/${segments.join('/')}` : '';