forked from animo/animo-demo
-
Notifications
You must be signed in to change notification settings - Fork 18
fix: repair app install QR redirects #603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a2da45f
fix: repair app install QR redirects
esune c9e826f
chore: fix lint errors
esune db31531
fix: improve dark mode QR readability
esune c06ec63
docs: remove duplicated .env section
esune 38c5a26
fix: use absolute install QR URLs
esune File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| # Vite exposes only variables prefixed with VITE_ to client code. | ||
| # Vite exposes only variables prefixed with VITE_ to client code. For phone testing, | ||
| # use a LAN address or HTTPS tunnel instead of 127.0.0.1, which points to the phone. | ||
| VITE_HOST_BACKEND=http://127.0.0.1:5000 | ||
| VITE_BASE_ROUTE=/digital-trust/showcase | ||
| VITE_INSIGHTS_PROJECT_ID= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { DEFAULT_ANDROID_APP_URL, DEFAULT_APPLE_APP_URL, getAppStoreRedirectUrl } from '../appStoreRedirect' | ||
|
|
||
| describe('getAppStoreRedirectUrl', () => { | ||
| it('redirects Android clients to Google Play by default', () => { | ||
| expect(getAppStoreRedirectUrl('Mozilla/5.0 (Linux; Android 14; Pixel 8)')).toBe(DEFAULT_ANDROID_APP_URL) | ||
| }) | ||
|
|
||
| it('redirects Apple clients to the App Store by default', () => { | ||
| expect(getAppStoreRedirectUrl('Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X)')).toBe(DEFAULT_APPLE_APP_URL) | ||
| }) | ||
|
|
||
| it('uses Google Play for unknown clients', () => { | ||
| expect(getAppStoreRedirectUrl('Mozilla/5.0 (X11; Linux x86_64)')).toBe(DEFAULT_ANDROID_APP_URL) | ||
| }) | ||
|
|
||
| it('supports configured store URLs', () => { | ||
| expect( | ||
| getAppStoreRedirectUrl('Mozilla/5.0 (Linux; Android 14)', { | ||
| android: 'https://example.com/android', | ||
| apple: 'https://example.com/apple', | ||
| }), | ||
| ).toBe('https://example.com/android') | ||
| }) | ||
|
|
||
| it('honors an explicit platform for store badge links', () => { | ||
| const links = { android: 'https://example.com/android', apple: 'https://example.com/apple' } | ||
|
|
||
| expect(getAppStoreRedirectUrl('Mozilla/5.0 (X11; Linux x86_64)', links, 'apple')).toBe('https://example.com/apple') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| export const DEFAULT_ANDROID_APP_URL = 'https://play.google.com/store/apps/details?id=ca.bc.gov.id.servicescard' | ||
| export const DEFAULT_APPLE_APP_URL = 'https://apps.apple.com/us/app/bc-services-card/id1234298467' | ||
|
|
||
| export interface AppStoreLinks { | ||
| android: string | ||
| apple: string | ||
| } | ||
|
|
||
| export type AppStorePlatform = 'android' | 'apple' | ||
|
|
||
| export const getAppStoreLinks = (): AppStoreLinks => ({ | ||
| android: process.env.ANDROID_APP_STORE_URL || DEFAULT_ANDROID_APP_URL, | ||
| apple: process.env.APPLE_APP_STORE_URL || DEFAULT_APPLE_APP_URL, | ||
| }) | ||
|
|
||
| export const getAppStoreRedirectUrl = ( | ||
| userAgent: string | undefined, | ||
| links: AppStoreLinks = getAppStoreLinks(), | ||
| platform?: AppStorePlatform, | ||
| ): string => { | ||
| if (platform) { | ||
| return links[platform] | ||
| } | ||
|
|
||
| const appleMatchers = [/iPhone/i, /iPad/i, /iPod/i] | ||
| const isApple = appleMatchers.some((matcher) => userAgent?.match(matcher)) | ||
|
|
||
| return isApple ? links.apple : links.android | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.