Browse Source

fix: android crash

Tienson Qin 3 years ago
parent
commit
5fcd166b96
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/main/frontend/fs/capacitor_fs.cljs

+ 5 - 1
src/main/frontend/fs/capacitor_fs.cljs

@@ -116,7 +116,11 @@
     ;; Too dangerious!!! We'll never implement this.
     nil)
   (read-file [this dir path _options]
-    (let [path (str dir path)]
+    (let [path (str dir path)
+          path (if (or (string/starts-with? path "file:")
+                       (string/starts-with? path "content:"))
+                 path
+                 (str "file:///" (string/replace path #"^/+" "")))]
       (->
        (p/let [content (.readFile Filesystem
                                   (clj->js