diff --git a/deps/common/src/logseq/common/path.cljs b/deps/common/src/logseq/common/path.cljs index 9d3dcc2df..af22e2abc 100644 --- a/deps/common/src/logseq/common/path.cljs +++ b/deps/common/src/logseq/common/path.cljs @@ -315,5 +315,5 @@ This is a loose check, it only checks if there is a valid protocol prefix." [p] - (boolean (and (re-find #"^[a-zA-Z0-9_+\-\.]+:" p) + (boolean (and (re-find #"^[a-zA-Z0-9_+\-\.]{2,}:" p) ;; HACK: avoid matching windows drive (not (string/includes? p " "))))) diff --git a/deps/common/test/logseq/common/path_test.cljs b/deps/common/test/logseq/common/path_test.cljs index 02bf0aa20..36fde4b73 100644 --- a/deps/common/test/logseq/common/path_test.cljs +++ b/deps/common/test/logseq/common/path_test.cljs @@ -45,3 +45,15 @@ (is (false? (path/absolute? "test.md"))) (is (false? (path/absolute? "test"))) (is (false? (path/absolute? "D:test.md"))))) + +(deftest protocol-url + (testing "protocol url" + (is (true? (path/protocol-url? "mailto:help@logseq.com"))) + (is (true? (path/protocol-url? "https://logseq.com"))) + (is (true? (path/protocol-url? "ftp://logseq.com"))) + (is (true? (path/protocol-url? "file:///home/xxx/logseq/test.md"))) + (is (true? (path/protocol-url? "assets:///home/xxx/logseq/test.md"))) + (is (false? (path/protocol-url? "logseq/test.md"))) + (is (false? (path/protocol-url? "test.md"))) + (is (false? (path/protocol-url? "test"))) + (is (false? (path/protocol-url? "D:test.md")))))