blob: 0f24dd678c089b8d6619e6ccdb79ba901ddb5577 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import {Linking} from 'react-native'
import {isIOS, isAndroid, 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> {
if (isNative) {
const url = await Linking.getInitialURL()
if (url) {
return url
}
return makeAppUrl()
} else {
// @ts-ignore window exists -prf
return window.location.toString()
}
}
export function clearHash() {
if (isWeb) {
// @ts-ignore window exists -prf
window.location.hash = ''
}
}
|