fix(ios): write file with special chars in filename

CJK, spaces, etc.
pull/3535/head
leizhe 2021-12-17 20:02:18 +08:00 committed by Tienson Qin
parent 3bcd0bdf3f
commit 0acfd917b3
1 changed files with 11 additions and 1 deletions

View File

@ -91,6 +91,16 @@
result (js->clj result :keywordize-keys true)]
(map (fn [result] (update result :uri clean-uri)) result)))
(defn- encode-path [orig-dir orig-path]
(let [[dir path] (map #(-> (string/replace % "file://" "")
(string/replace "file:" ""))
[orig-dir orig-path])
path (string/escape path {\ "%20"})
path-diff (string/replace path dir "")]
(str orig-dir (-> path-diff
futil/url-decode
futil/url-encode))))
(defrecord Capacitorfs []
protocol/Fs
(mkdir! [this dir]
@ -130,7 +140,7 @@
(write-file! [this repo dir path content {:keys [ok-handler error-handler] :as opts}]
(let [path (cond
(= (util/platform) "ios")
(str dir path)
(encode-path dir path)
(string/starts-with? path (config/get-repo-dir repo))
path