Skip to content

Commit 5ddd3fb

Browse files
committed
🎨 Improve link parsing siyuan-note/siyuan#14076
1 parent 0b113a2 commit 5ddd3fb

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

javascript/lute.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascript/lute.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lute.go

+4
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ func (lute *Lute) IsValidLinkDest(str string) bool {
173173

174174
func (lute *Lute) GetLinkDest(str string) string {
175175
str = strings.TrimSpace(str)
176+
if strings.HasPrefix(str, "file://") {
177+
return str
178+
}
179+
176180
luteEngine := New()
177181
luteEngine.ParseOptions.GFMAutoLink = true
178182
tree := parse.Parse("", []byte(str), luteEngine.ParseOptions)

test/link_dest_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ func TestGetLinkDest(t *testing.T) {
5858
if "https://abc.pm/" != dest {
5959
t.Fatalf("get link dest failed")
6060
}
61+
62+
dest = luteEngine.GetLinkDest("file://D:\\Admin\\Downloads\\隔壁叔叔过年还在玩思源.jpg")
63+
if "file://D:\\Admin\\Downloads\\隔壁叔叔过年还在玩思源.jpg" != dest {
64+
t.Fatalf("get link dest failed")
65+
}
6166
}
6267

6368
func TestIsValidLinkDest(t *testing.T) {

0 commit comments

Comments
 (0)