[GITEA] Fix relative links rendering
- Relative links were not properly being rendered, because the links were being made absolute against the repository URL instead of repository URL + /src/branch, which leads to incorrect links. - Restore the 'old' behaviour. When there's branch information, that should be used as base for links. - Adjusts the test cases. - Regression of637451a45e
- Resolves https://codeberg.org/Codeberg/Community/issues/1411 (cherry picked from commit0e9d52e291
)
This commit is contained in:
parent
ee1ead8189
commit
c67255192e
2 changed files with 4 additions and 2 deletions
|
@ -137,6 +137,8 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa
|
||||||
var base string
|
var base string
|
||||||
if ctx.IsWiki {
|
if ctx.IsWiki {
|
||||||
base = ctx.Links.WikiLink()
|
base = ctx.Links.WikiLink()
|
||||||
|
} else if ctx.Links.HasBranchInfo() {
|
||||||
|
base = ctx.Links.SrcLink()
|
||||||
} else {
|
} else {
|
||||||
base = ctx.Links.Base
|
base = ctx.Links.Base
|
||||||
}
|
}
|
||||||
|
|
|
@ -975,7 +975,7 @@ space</p>
|
||||||
Expected: `<p>space @mention-user<br/>
|
Expected: `<p>space @mention-user<br/>
|
||||||
/just/a/path.bin<br/>
|
/just/a/path.bin<br/>
|
||||||
<a href="https://example.com/file.bin" rel="nofollow">https://example.com/file.bin</a><br/>
|
<a href="https://example.com/file.bin" rel="nofollow">https://example.com/file.bin</a><br/>
|
||||||
<a href="/user/repo/file.bin" rel="nofollow">local link</a><br/>
|
<a href="/user/repo/src/branch/main/file.bin" rel="nofollow">local link</a><br/>
|
||||||
<a href="https://example.com" rel="nofollow">remote link</a><br/>
|
<a href="https://example.com" rel="nofollow">remote link</a><br/>
|
||||||
<a href="/user/repo/src/branch/main/file.bin" rel="nofollow">local link</a><br/>
|
<a href="/user/repo/src/branch/main/file.bin" rel="nofollow">local link</a><br/>
|
||||||
<a href="https://example.com" rel="nofollow">remote link</a><br/>
|
<a href="https://example.com" rel="nofollow">remote link</a><br/>
|
||||||
|
@ -1088,7 +1088,7 @@ space</p>
|
||||||
Expected: `<p>space @mention-user<br/>
|
Expected: `<p>space @mention-user<br/>
|
||||||
/just/a/path.bin<br/>
|
/just/a/path.bin<br/>
|
||||||
<a href="https://example.com/file.bin" rel="nofollow">https://example.com/file.bin</a><br/>
|
<a href="https://example.com/file.bin" rel="nofollow">https://example.com/file.bin</a><br/>
|
||||||
<a href="/user/repo/file.bin" rel="nofollow">local link</a><br/>
|
<a href="/user/repo/src/branch/main/sub/folder/file.bin" rel="nofollow">local link</a><br/>
|
||||||
<a href="https://example.com" rel="nofollow">remote link</a><br/>
|
<a href="https://example.com" rel="nofollow">remote link</a><br/>
|
||||||
<a href="/user/repo/src/branch/main/sub/folder/file.bin" rel="nofollow">local link</a><br/>
|
<a href="/user/repo/src/branch/main/sub/folder/file.bin" rel="nofollow">local link</a><br/>
|
||||||
<a href="https://example.com" rel="nofollow">remote link</a><br/>
|
<a href="https://example.com" rel="nofollow">remote link</a><br/>
|
||||||
|
|
Loading…
Reference in a new issue