mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 21:16:26 +01:00 
			
		
		
		
	Respect branch info for relative links (#28909)
Fix #28904 Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
		
							parent
							
								
									eaab89c46b
								
							
						
					
					
						commit
						c46316f7ae
					
				@ -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
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
@ -765,7 +765,7 @@ space</p>
 | 
			
		||||
			Expected: `<p>space @mention-user<br/>
 | 
			
		||||
/just/a/path.bin<br/>
 | 
			
		||||
<a href="https://example.com/file.bin" rel="nofollow">https://example.com/file.bin</a><br/>
 | 
			
		||||
<a href="/user/repo/file.bin" rel="nofollow">local link</a><br/>
 | 
			
		||||
<a href="/user/repo/src/branch/main/file.bin" rel="nofollow">local link</a><br/>
 | 
			
		||||
<a href="https://example.com" rel="nofollow">remote link</a><br/>
 | 
			
		||||
<a href="/user/repo/src/branch/main/file.bin" rel="nofollow">local link</a><br/>
 | 
			
		||||
<a href="https://example.com" rel="nofollow">remote link</a><br/>
 | 
			
		||||
@ -878,7 +878,7 @@ space</p>
 | 
			
		||||
			Expected: `<p>space @mention-user<br/>
 | 
			
		||||
/just/a/path.bin<br/>
 | 
			
		||||
<a href="https://example.com/file.bin" rel="nofollow">https://example.com/file.bin</a><br/>
 | 
			
		||||
<a href="/user/repo/file.bin" rel="nofollow">local link</a><br/>
 | 
			
		||||
<a href="/user/repo/src/branch/main/sub/folder/file.bin" rel="nofollow">local link</a><br/>
 | 
			
		||||
<a href="https://example.com" rel="nofollow">remote link</a><br/>
 | 
			
		||||
<a href="/user/repo/src/branch/main/sub/folder/file.bin" rel="nofollow">local link</a><br/>
 | 
			
		||||
<a href="https://example.com" rel="nofollow">remote link</a><br/>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user