Add temporary web event listener for deep link navigation testing in web

browser
This commit is contained in:
Matthew Remmel
2025-08-26 12:43:44 -04:00
parent b81f7c9ed3
commit bb1ff4fb11
+13
View File
@@ -110,11 +110,24 @@
// Listen for deep link events
App.addListener("appUrlOpen", (event: URLOpenListenerEvent) => {
console.log(event)
const url = new URL(event.url)
const target = `${url.pathname}${url.search}${url.hash}`
goto(target, {replaceState: false, noScroll: false})
})
// TEMP: Since the capacitor event won't fire in web, dropping equivalent implementation here for testing navigation
//
// Event can be manually triggered in web console with: `window.dispatchEvent(new CustomEvent("appUrlOpen", { detail: { url: "foobar:///.well-known/apple-app-site-association" } }) );`
window.addEventListener("appUrlOpen", (_event: Event) => {
console.log(_event)
const event = _event as CustomEvent<{url: string}>
const url = new URL(event.detail.url)
const target = `${url.pathname}${url.search}${url.hash}`
console.log(target)
goto(target, {replaceState: false, noScroll: false})
})
// Nstart login
if (window.location.hash?.startsWith("#nostr-login")) {
const params = new URLSearchParams(window.location.hash.slice(1))