mirror of
https://github.com/go-gitea/gitea
synced 2025-07-19 00:38:36 +00:00
Refactor markup render to fix various path problems (#34114)
* Fix #33972 * Use consistent path resolving for links and medias. * No need to make the markup renders to resolve the paths, instead, the paths are all correctly resolved in the "post process" step. * Fix #33274 * Since 1.23, all paths starting with "/" are relative to current render context (for example: the current repo branch) * Introduce `/:root/path-relative-to-root`, then the path will be rendered as relative to "ROOT_URL"
This commit is contained in:
@@ -30,18 +30,16 @@ func (r *RepoWiki) IsCommitIDExisting(commitID string) bool {
|
||||
return r.commitChecker.IsCommitIDExisting(commitID)
|
||||
}
|
||||
|
||||
func (r *RepoWiki) ResolveLink(link string, likeType markup.LinkType) string {
|
||||
finalLink := link
|
||||
switch likeType {
|
||||
case markup.LinkTypeApp:
|
||||
finalLink = r.ctx.ResolveLinkApp(link)
|
||||
case markup.LinkTypeDefault:
|
||||
finalLink = r.ctx.ResolveLinkRelative(path.Join(r.repoLink, "wiki", r.opts.currentRefPath), r.opts.currentTreePath, link)
|
||||
case markup.LinkTypeMedia:
|
||||
func (r *RepoWiki) ResolveLink(link, preferLinkType string) (finalLink string) {
|
||||
linkType, link := markup.ParseRenderedLink(link, preferLinkType)
|
||||
switch linkType {
|
||||
case markup.LinkTypeRoot:
|
||||
finalLink = r.ctx.ResolveLinkRoot(link)
|
||||
case markup.LinkTypeMedia, markup.LinkTypeRaw:
|
||||
finalLink = r.ctx.ResolveLinkRelative(path.Join(r.repoLink, "wiki/raw", r.opts.currentRefPath), r.opts.currentTreePath, link)
|
||||
case markup.LinkTypeRaw: // wiki doesn't use it
|
||||
default:
|
||||
finalLink = r.ctx.ResolveLinkRelative(path.Join(r.repoLink, "wiki", r.opts.currentRefPath), r.opts.currentTreePath, link)
|
||||
}
|
||||
|
||||
return finalLink
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user