Skip to content

Commit

Permalink
Merge pull request #2944 from tloncorp/po/land-1047-provide-fallback-…
Browse files Browse the repository at this point in the history
…if-branchio-blocked

lure: provide a fallback url if branch.io is blocked (or down)
  • Loading branch information
patosullivan authored Oct 11, 2023
2 parents 174a8a8 + 4bc3a82 commit 1dcd014
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ui/src/logic/branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const getDeepLink = async (alias: string) => {

export const createDeepLink = async (canonicalUrl: string, lure: string) => {
const alias = lure.replace('~', '').replace('/', '-');
let url = await getDeepLink(alias);
let url = await getDeepLink(alias).catch(() => canonicalUrl);
if (!url) {
const response = await fetchBranchApi('/v1/url', {
method: 'POST',
Expand All @@ -34,8 +34,9 @@ export const createDeepLink = async (canonicalUrl: string, lure: string) => {
},
}),
});

if (!response.ok) {
return undefined;
return canonicalUrl;
}

({ url } = (await response.json()) as { url: string });
Expand Down

0 comments on commit 1dcd014

Please sign in to comment.