Skip to content

Commit

Permalink
chore: rm unused safe-path-join
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Apr 24, 2023
1 parent 35eed4c commit f0faf65
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
7 changes: 0 additions & 7 deletions src/main/frontend/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,6 @@
(if (string? s)
(string/lower-case s) s))

#?(:cljs
(defn safe-path-join [prefix & paths]
(let [path (apply node-path.join (cons prefix paths))]
(if (and (electron?) (gstring/caseInsensitiveStartsWith path "file://"))
(gp-util/safe-decode-uri-component (subs path 7))
path))))

(defn trim-safe
[s]
(when s
Expand Down
13 changes: 1 addition & 12 deletions src/test/frontend/util_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@
(is (= 2 (util/safe-inc-current-pos-from-start "abcde" 1)))
(is (= 1 (util/safe-inc-current-pos-from-start "中文" 0)))))

(deftest test-safe-path-join
(testing "safe path join with custom schema"
(is (= (util/node-path.join "a/b" "c/d.md") "a/b/c/d.md"))
(is (= (util/node-path.join "a/b/c" "../../d.md") "a/d.md"))
(is (= (util/node-path.join "file:///a/b" "c/d.md") "file:///a/b/c/d.md"))
(is (= (util/node-path.join "file:///a/b" "../d.md") "file:///a/d.md"))
(is (= (util/node-path.join "file:///a a2/b" "c/d.md") "file:///a a2/b/c/d.md"))
(is (= (util/node-path.join "C:/a2/b" "c/d.md") "C:/a2/b/c/d.md"))
(is (= (util/node-path.join "content://a/b" "../d.md") "content://a/d.md"))
(is (= (util/node-path.join "https://logseq.com/a/b" "c/d.md") "https://logseq.com/a/b/c/d.md"))))

(deftest test-memoize-last
(testing "memoize-last add test"
(let [actual-ops (atom 0)
Expand Down Expand Up @@ -120,4 +109,4 @@
(is (= (config/ext-of-video? "file.mp3") false))
(is (= (config/ext-of-image? "file.svg") true))
(is (= (config/ext-of-image? "a.file.png") true))
(is (= (config/ext-of-image? "file.tiff") false))))
(is (= (config/ext-of-image? "file.tiff") false))))

0 comments on commit f0faf65

Please sign in to comment.