mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Fix team links in HTML rendering (#9127)
* Fix team links in HTML rendering * Fix check and lint
This commit is contained in:
		
				
					committed by
					
						
						techknowlogick
					
				
			
			
				
	
			
			
			
						parent
						
							7523314ef8
						
					
				
				
					commit
					f25fd5c8eb
				
			@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user