fix(auth): fix Android deep link intent URL format for Google OAuth
The intent:// URL in renderTauriDeepLinkPage was intent:/path (single slash), producing zeavisedu:/login?token=xxx — a non-hierarchical URL that new URL() cannot parse. Fixed to intent://login/path which produces a proper hierarchical URI (zeavisedu://login/login?token=xxx). Also hardened setupDeepLinkHandler to handle both double-slash (://) and single-slash (:/) custom-scheme URLs as fallback. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -35,20 +35,25 @@ export async function setupDeepLinkHandler(): Promise<void> {
|
||||
const { onOpenUrl } = await import('@tauri-apps/plugin-deep-link');
|
||||
onOpenUrl((urls) => {
|
||||
for (const url of urls) {
|
||||
// url looks like: zeavisedu://zeavisedu.asepharyana.my.id/login?token=xxx
|
||||
// url looks like: zeavisedu://login/login?token=xxx
|
||||
// Extract path + query after the host
|
||||
try {
|
||||
const u = new URL(url);
|
||||
const target = u.pathname + u.search + u.hash;
|
||||
if (target && target !== '/') {
|
||||
window.location.href = target;
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
// If URL parsing fails, try to extract everything after the scheme
|
||||
const match = url.match(/^[^:]+:\/\/(?:[^/]+)?(\/.*)?$/);
|
||||
if (match?.[1]) {
|
||||
window.location.href = match[1];
|
||||
}
|
||||
} catch { /* try fallback below */ }
|
||||
|
||||
// Fallback: extract everything after scheme, handling both // and /
|
||||
let match = url.match(/^[^:]+:\/\/(?:[^/]+)?(\/.*)?$/);
|
||||
if (!match) {
|
||||
// Also handle single-slash non-hierarchical URLs (e.g. zeavisedu:/path)
|
||||
match = url.match(/^[^:]+:\/(\/.*)?$/);
|
||||
}
|
||||
if (match?.[1]) {
|
||||
window.location.href = match[1];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user