about summary refs log tree commit diff
path: root/src/platform/urls.tsx
diff options
context:
space:
mode:
authorMichael Staub <michael.staub@brightmachines.com>2023-02-23 13:52:12 -0800
committerMichael Staub <michael.staub@brightmachines.com>2023-02-23 13:52:12 -0800
commitf709c50809b17ce2ae6f789b728235495086e247 (patch)
tree6c0c0903217f1a708ea09118f7b30a4475d1aef0 /src/platform/urls.tsx
parenta014b4e6cbe9c397233c2ffe16c4417c68d1f15f (diff)
downloadvoidsky-f709c50809b17ce2ae6f789b728235495086e247.tar.zst
fix: browser history
Diffstat (limited to 'src/platform/urls.tsx')
-rw-r--r--src/platform/urls.tsx35
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()
+  }
+}