refactor: external render (#38885)

make the "command variable replacement" more accurate and
OS-independent, add a test for it.
This commit is contained in:
wxiaoguang authored and GitHub committed 2026-08-12 19:30:26 +00:00
1 parent 8161479fde
commit 53d7d3f053
5 files changed
+60 -27

No files matched your search

+1
View File
@@ -64,6 +64,7 @@ func RenderMarkup(ctx *context.Base, ctxRepo *context.Repository, mode, text, ur
treePath = path.Dir(filePath) // it is "doc" if filePath is "doc/CHANGE.md"
refPath = strings.Join(fields[3:], "/") // it is "branch/features/feat-12/doc"
refPath = strings.TrimSuffix(refPath, "/"+treePath) // now we get the correct branch path: "branch/features/feat-12"
refPath = util.PathEscapeSegments(refPath)
} else if fields = strings.SplitN(repoLinkPath, "/", 3); len(fields) == 2 {
repoOwnerName, repoName = fields[0], fields[1]
}