fix mini app bot father

This commit is contained in:
lendry
2026-06-26 11:08:10 +03:00
parent 489b4d4a23
commit 7ed7cbdd16
7 changed files with 174 additions and 31 deletions

View File

@@ -0,0 +1,22 @@
export function normalizeMiniAppUrl(url: string) {
if (typeof window === 'undefined') return url;
try {
const parsed = new URL(url, window.location.href);
if (parsed.pathname.startsWith('/mini-apps/')) {
return `${window.location.origin}${parsed.pathname}${parsed.search}${parsed.hash}`;
}
return parsed.toString();
} catch {
return url;
}
}
export function resolveMiniAppTargetOrigin(iframeSrc: string | null | undefined, fallback: string) {
if (!iframeSrc) return fallback;
try {
return new URL(iframeSrc, fallback).origin;
} catch {
return fallback;
}
}