about summary refs log tree commit diff
path: root/src/platform/urls.tsx
blob: 514bde43e2efab90098c79ab5c876cc86e9a1d31 (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
import {Linking} from 'react-native'

import {isNative, isWeb} from './detection'

export async function getInitialURL(): Promise<string | undefined> {
  if (isNative) {
    const url = await Linking.getInitialURL()
    if (url) {
      return url
    }
    return undefined
  } else {
    // @ts-ignore window exists -prf
    if (window.location.pathname !== '/') {
      return window.location.pathname
    }
    return undefined
  }
}

export function clearHash() {
  if (isWeb) {
    // @ts-ignore window exists -prf
    window.location.hash = ''
  }
}