summaryrefslogtreecommitdiffstats
path: root/modules/markup/html.go
diff options
context:
space:
mode:
authormrsdizzie <info@mrsdizzie.com>2019-04-16 03:53:57 -0400
committerzeripath <art27@cantab.net>2019-04-16 08:53:57 +0100
commit1bce1894f5ceefff2af0ebb95d060cec6f9c21b2 (patch)
tree280e3b2cb5e7e4306e983d030a7d0018292414e0 /modules/markup/html.go
parente98565ddc71013bc4bc5537f15f545cf909fac3a (diff)
downloadgitea-1bce1894f5ceefff2af0ebb95d060cec6f9c21b2.tar.gz
gitea-1bce1894f5ceefff2af0ebb95d060cec6f9c21b2.zip
Use ctx.metas for SHA hash links (#6645)
Since #6273 was merged, we now have access to proper context metas always. Update SHA generated links to use these instead of urlPrefix. Update tests as well. Fixes #4536.
Diffstat (limited to 'modules/markup/html.go')
-rw-r--r--modules/markup/html.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go
index 930c6b3a3e..adc2bef530 100644
--- a/modules/markup/html.go
+++ b/modules/markup/html.go
@@ -625,6 +625,9 @@ func crossReferenceIssueIndexPatternProcessor(ctx *postProcessCtx, node *html.No
// fullSha1PatternProcessor renders SHA containing URLs
func fullSha1PatternProcessor(ctx *postProcessCtx, node *html.Node) {
+ if ctx.metas == nil {
+ return
+ }
m := anySHA1Pattern.FindStringSubmatchIndex(node.Data)
if m == nil {
return
@@ -686,7 +689,7 @@ func sha1CurrentPatternProcessor(ctx *postProcessCtx, node *html.Node) {
// Although unlikely, deadbeef and 1234567 are valid short forms of SHA1 hash
// as used by git and github for linking and thus we have to do similar.
replaceContent(node, m[2], m[3],
- createCodeLink(util.URLJoin(ctx.urlPrefix, "commit", hash), base.ShortSha(hash)))
+ createCodeLink(util.URLJoin(setting.AppURL, ctx.metas["user"], ctx.metas["repo"], "commit", hash), base.ShortSha(hash)))
}
// emailAddressProcessor replaces raw email addresses with a mailto: link.