Skip to content

Commit

Permalink
fine tune comments and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Nov 23, 2024
1 parent 312fc2b commit c54a732
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion models/renderhelper/repo_wiki.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
12 changes: 12 additions & 0 deletions models/renderhelper/repo_wiki_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

0 comments on commit c54a732

Please sign in to comment.