mirror of
https://github.com/logseq/logseq.git
synced 2026-04-28 16:15:21 +00:00
fix(sync): unify path-normalize and filter out un-normalized files
This commit is contained in:
@@ -235,8 +235,7 @@
|
||||
path))
|
||||
path))
|
||||
|
||||
(defn normalize-file-protocol-path [dir path & {:keys [normalize?]
|
||||
:or {normalize? true}}]
|
||||
(defn normalize-file-protocol-path [dir path]
|
||||
(let [dir (some-> dir (string/replace #"/+$" ""))
|
||||
dir (if (and (not-empty dir) (string/starts-with? dir "/"))
|
||||
(do
|
||||
@@ -244,15 +243,16 @@
|
||||
(str "file://" (js/encodeURI dir)))
|
||||
dir)
|
||||
path (some-> path (string/replace #"^/+" ""))
|
||||
normalize-f (if normalize? gp-util/path-normalize identity)
|
||||
normalize-f gp-util/path-normalize
|
||||
encodeURI-f js/encodeURI
|
||||
safe-encode-url #(let [encoded-chars?
|
||||
(and (string? %) (boolean (re-find #"(?i)%[0-9a-f]{2}" %)))]
|
||||
(cond
|
||||
(not encoded-chars?)
|
||||
(js/encodeURI %)
|
||||
(encodeURI-f (normalize-f %))
|
||||
|
||||
:else
|
||||
(js/encodeURI (normalize-f (js/decodeURI %)))))
|
||||
(encodeURI-f (normalize-f (js/decodeURI %)))))
|
||||
path' (cond
|
||||
(and path (string/starts-with? path "file:/"))
|
||||
(safe-encode-url path)
|
||||
|
||||
Reference in New Issue
Block a user