fix(fs): windows unc path support

This commit is contained in:
Andelf
2023-11-23 13:22:26 +08:00
parent aa19b511f6
commit 61a3c19176
4 changed files with 42 additions and 6 deletions

View File

@@ -69,7 +69,19 @@
url (decode-protected-assets-schema-path url)
path (string/replace url "assets://" "")
path (js/decodeURIComponent path)]
(callback #js {:path path}))))
(cond (or (string/starts-with? path "/")
(re-find #"(?i)^/[a-zA-Z]:" path))
(callback #js {:path path})
;; assume winwdows unc path
utils/win32?
(do (logger/debug :resolve-assets-url url)
(callback #js {:path (str "//" path)}))
:else
(do
(logger/warn ::resolve-assets-url "Unknown assets url" url)
(callback #js {:path path}))))))
(.registerFileProtocol
protocol FILE_LSP_SCHEME

View File

@@ -76,8 +76,9 @@
(str "assets://" (string/replace rpath' (str "@" (:name alias)) (:dir alias)))
(if has-schema? (path/path-join graph-root rpath)
(path/path-join "file://" graph-root rpath))))]
(if has-schema?
(path/path-join graph-root rpath)
(path/prepend-protocol "file:" (path/path-join graph-root rpath)))))]
(convert-platform-protocol ret)))))
(defn normalize-asset-resource-url

View File

@@ -1470,7 +1470,7 @@
(assets-handler/resolve-asset-real-path-url (state/get-current-repo) path)
(util/electron?)
(path/path-join "assets://" full-path)
(path/prepend-protocol "assets:" full-path)
(mobile-util/native-platform?)
(mobile-util/convert-file-src full-path)