From 8766f65addcce5fcfafc915edc3d299f7e2b96fa Mon Sep 17 00:00:00 2001
From: Giteabot
Date: Thu, 25 Jan 2024 17:40:29 +0800
Subject: [PATCH] Respect branch info for relative links (#28909) (#28922)
Backport #28909 by @KN4CK3R
Fix #28904
Co-authored-by: KN4CK3R
---
modules/markup/markdown/goldmark.go | 2 ++
modules/markup/markdown/markdown_test.go | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/modules/markup/markdown/goldmark.go b/modules/markup/markdown/goldmark.go
index b92b90561b990..1db3cbad7e1b0 100644
--- a/modules/markup/markdown/goldmark.go
+++ b/modules/markup/markdown/goldmark.go
@@ -137,6 +137,8 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa
var base string
if ctx.IsWiki {
base = ctx.Links.WikiLink()
+ } else if ctx.Links.HasBranchInfo() {
+ base = ctx.Links.SrcLink()
} else {
base = ctx.Links.Base
}
diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go
index 6f2bbae6e0c16..5216d1973cf58 100644
--- a/modules/markup/markdown/markdown_test.go
+++ b/modules/markup/markdown/markdown_test.go
@@ -765,7 +765,7 @@ space
Expected: `space @mention-user
/just/a/path.bin
https://example.com/file.bin
-local link
+local link
remote link
local link
remote link
@@ -878,7 +878,7 @@ space
Expected: `space @mention-user
/just/a/path.bin
https://example.com/file.bin
-local link
+local link
remote link
local link
remote link