mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-02 18:45:34 +08:00
fix: ignore cross-origin basename hints
This commit is contained in:
@@ -38,7 +38,12 @@ function detectRouterBasename() {
|
|||||||
let detectedBasename = '';
|
let detectedBasename = '';
|
||||||
for (const candidate of candidatePaths) {
|
for (const candidate of candidatePaths) {
|
||||||
try {
|
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(/\/+$/, '');
|
const normalizedPathname = pathname.replace(/\/+$/, '');
|
||||||
|
|
||||||
let normalized = '';
|
let normalized = '';
|
||||||
@@ -53,7 +58,7 @@ function detectRouterBasename() {
|
|||||||
const match = candidate.kind === 'manifest' ? manifestMatch : iconMatch;
|
const match = candidate.kind === 'manifest' ? manifestMatch : iconMatch;
|
||||||
if (match?.[1]) {
|
if (match?.[1]) {
|
||||||
const segments = match[1].split('/').filter(Boolean);
|
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();
|
segments.pop();
|
||||||
}
|
}
|
||||||
normalized = segments.length > 0 ? `/${segments.join('/')}` : '';
|
normalized = segments.length > 0 ? `/${segments.join('/')}` : '';
|
||||||
|
|||||||
Reference in New Issue
Block a user