diff options
author | guillep2k <18600385+guillep2k@users.noreply.github.com> | 2019-11-24 13:34:44 -0300 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-11-24 11:34:44 -0500 |
commit | f25fd5c8ebc83c664b5ac1752e1c4dd11edc02a2 (patch) | |
tree | b0e47d6b19a06dd93619013bfa25b5142acb1771 /modules/markup | |
parent | 7523314ef8564e2c016168d4628f3ab11e27d7ba (diff) | |
download | gitea-f25fd5c8ebc83c664b5ac1752e1c4dd11edc02a2.tar.gz gitea-f25fd5c8ebc83c664b5ac1752e1c4dd11edc02a2.zip |
Fix team links in HTML rendering (#9127)
* Fix team links in HTML rendering
* Fix check and lint
Diffstat (limited to 'modules/markup')
-rw-r--r-- | modules/markup/html.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go index 924d0089a5..e5a475aff8 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -432,14 +432,20 @@ func replaceContentList(node *html.Node, i, j int, newNodes []*html.Node) { } } -func mentionProcessor(_ *postProcessCtx, node *html.Node) { +func mentionProcessor(ctx *postProcessCtx, node *html.Node) { // We replace only the first mention; other mentions will be addressed later found, loc := references.FindFirstMentionBytes([]byte(node.Data)) if !found { return } mention := node.Data[loc.Start:loc.End] - replaceContent(node, loc.Start, loc.End, createLink(util.URLJoin(setting.AppURL, mention[1:]), mention, "mention")) + var teams string + teams, ok := ctx.metas["teams"] + if ok && strings.Contains(teams, ","+strings.ToLower(mention[1:])+",") { + replaceContent(node, loc.Start, loc.End, createLink(util.URLJoin(setting.AppURL, "org", ctx.metas["org"], "teams", mention[1:]), mention, "mention")) + } else { + replaceContent(node, loc.Start, loc.End, createLink(util.URLJoin(setting.AppURL, mention[1:]), mention, "mention")) + } } func shortLinkProcessor(ctx *postProcessCtx, node *html.Node) { |