forked from forgejo/forgejo
[BUG] Fix relative links on orgmode
- Backport of #2385 - For regular non-image nonvideo links, they should be made relative, this was done against `r.Ctx.Links.Base`, but since637451a45e
, that should instead be done by `SrcLink()` if there's branch information set in the context, because branch and treepath information are no longer set in `r.Ctx.Links.Base`. - This is consistent with how #2166 _fixed_ relative links. - Media is not affected, `TestRender_Media` test doesn't fail. - Adds unit tests. - Ref https://codeberg.org/Codeberg/Community/issues/1485 (cherry picked from commita2442793d2
)
This commit is contained in:
parent
cd8a59e7bd
commit
fa700333ba
2 changed files with 57 additions and 3 deletions
|
@ -147,11 +147,21 @@ func (r *Writer) resolveLink(node org.Node) string {
|
|||
}
|
||||
if len(link) > 0 && !markup.IsLinkStr(link) &&
|
||||
link[0] != '#' && !strings.HasPrefix(link, mailto) {
|
||||
base := r.Ctx.Links.Base
|
||||
|
||||
var base string
|
||||
if r.Ctx.IsWiki {
|
||||
base = r.Ctx.Links.WikiLink()
|
||||
} else if r.Ctx.Links.HasBranchInfo() {
|
||||
base = r.Ctx.Links.SrcLink()
|
||||
} else {
|
||||
base = r.Ctx.Links.Base
|
||||
}
|
||||
|
||||
switch l.Kind() {
|
||||
case "image", "video":
|
||||
base = r.Ctx.Links.ResolveMediaLink(r.Ctx.IsWiki)
|
||||
}
|
||||
|
||||
link = util.URLJoin(base, link)
|
||||
}
|
||||
return link
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue