Skip to content

Commit

Permalink
fix deeplinks if protocol includes dash
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkNerdi committed May 28, 2024
1 parent b6d2298 commit 6e405f6
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ export function handleDeepLink(input: string): void {
}

try {
const url = new URL(input)
if (url.protocol !== `${process.env.APP_PROTOCOL}:`) {
const protocol = input.split('://')[0]

if (protocol !== process.env.APP_PROTOCOL) {
throw new Error(`Does not start with ${process.env.APP_PROTOCOL}://`)
}

const cleanedInput = input.replace(`${protocol}://`, 'https://')
const url = new URL(cleanedInput)

closePopup()
closeDrawer()

Expand All @@ -64,7 +68,6 @@ function handleDeepLinkForHostname(url: URL): void {
if (pathnameParts.length === 0 || !pathnameParts[0]) {
throw new Error('No operation specified in the URL')
}

switch (url.hostname as DeepLinkContext) {
case DeepLinkContext.Wallet:
get(dashboardRouter)?.goTo(DashboardRoute.Wallet)
Expand Down

0 comments on commit 6e405f6

Please sign in to comment.