fine tune comments and tests

This commit is contained in:
wxiaoguang 2024-11-23 12:38:45 +08:00
parent 312fc2bf59
commit c54a7328c4
2 changed files with 14 additions and 1 deletions

View File

@ -39,8 +39,9 @@ func (r *RepoWiki) ResolveLink(link string, likeType markup.LinkType) string {
finalLink = r.ctx.ResolveLinkRelative(path.Join(r.repoLink, "wiki", r.opts.currentRefPath), r.opts.currentTreePath, link)
case markup.LinkTypeMedia:
finalLink = r.ctx.ResolveLinkRelative(path.Join(r.repoLink, "wiki/raw", r.opts.currentRefPath), r.opts.currentTreePath, link)
// wiki doesn't use src or raw
case markup.LinkTypeRaw: // wiki doesn't use it
}
return finalLink
}

View File

@ -50,4 +50,16 @@ func TestRepoWiki(t *testing.T) {
<a href="/user2/repo1/wiki/raw/image" target="_blank" rel="nofollow noopener"><img src="/user2/repo1/wiki/raw/image" alt="./image"/></a></p>
`, rendered)
})
t.Run("PathInTag", func(t *testing.T) {
rctx := NewRenderContextRepoWiki(context.Background(), repo1).WithMarkupType(markdown.MarkupName)
rendered, err := markup.RenderString(rctx, `
<img src="LINK">
<video src="LINK">
`)
assert.NoError(t, err)
assert.Equal(t, `<a href="/user2/repo1/wiki/raw/LINK" target="_blank" rel="nofollow noopener"><img src="/user2/repo1/wiki/raw/LINK"/></a>
<video src="/user2/repo1/wiki/raw/LINK">
</video>`, rendered)
})
}