mirror of https://github.com/logseq/logseq
test(fs): simple test for protocol-url
parent
0c91829365
commit
880ea8b00e
|
@ -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 " ")))))
|
||||
|
|
|
@ -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")))))
|
||||
|
|
Loading…
Reference in New Issue