diff options
Diffstat (limited to 'src/platform')
-rw-r--r-- | src/platform/urls.tsx | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/platform/urls.tsx b/src/platform/urls.tsx index 0f24dd678..f544262d7 100644 --- a/src/platform/urls.tsx +++ b/src/platform/urls.tsx @@ -1,31 +1,20 @@ import {Linking} from 'react-native' -import {isIOS, isAndroid, isNative, isWeb} from './detection' +import {createBrowserHistory, createMemoryHistory} from 'history' +import {isNative, isWeb} from './detection' -export function makeAppUrl(path = '') { - if (isIOS) { - return `bskyapp://${path}` - } else if (isAndroid) { - return `bsky://app${path}` - } else { - // @ts-ignore window exists -prf - return `${window.location.origin}${path}` - } -} - -export function extractHashFragment(url: string): string { - return url.split('#')[1] || '' -} - -export async function getInitialURL(): Promise<string> { +export async function getInitialURL(): Promise<string | undefined> { if (isNative) { const url = await Linking.getInitialURL() if (url) { return url } - return makeAppUrl() + return undefined } else { // @ts-ignore window exists -prf - return window.location.toString() + if (window.location.pathname !== '/') { + return window.location.pathname + } + return undefined } } @@ -35,3 +24,11 @@ export function clearHash() { window.location.hash = '' } } + +export function getHistory() { + if (isWeb) { + return createBrowserHistory() + } else { + return createMemoryHistory() + } +} |