mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-03 21:08:25 +00:00 
			
		
		
		
	Fix legacy URL redirects (#3100)
This commit is contained in:
		@@ -48,6 +48,8 @@ func TestRedirectsNoLogin(t *testing.T) {
 | 
			
		||||
	var redirects = map[string]string{
 | 
			
		||||
		"/user2/repo1/commits/master":                "/user2/repo1/commits/branch/master",
 | 
			
		||||
		"/user2/repo1/src/master":                    "/user2/repo1/src/branch/master",
 | 
			
		||||
		"/user2/repo1/src/master/file.txt":           "/user2/repo1/src/branch/master/file.txt",
 | 
			
		||||
		"/user2/repo1/src/master/directory/file.txt": "/user2/repo1/src/branch/master/directory/file.txt",
 | 
			
		||||
	}
 | 
			
		||||
	for link, redirectLink := range redirects {
 | 
			
		||||
		req := NewRequest(t, "GET", link)
 | 
			
		||||
 
 | 
			
		||||
@@ -618,7 +618,11 @@ func RepoRefByType(refType RepoRefType) macaron.Handler {
 | 
			
		||||
 | 
			
		||||
			if refType == RepoRefLegacy {
 | 
			
		||||
				// redirect from old URL scheme to new URL scheme
 | 
			
		||||
				ctx.Redirect(path.Join(setting.AppSubURL, strings.TrimSuffix(ctx.Req.URL.String(), ctx.Params("*")), ctx.Repo.BranchNameSubURL()))
 | 
			
		||||
				ctx.Redirect(path.Join(
 | 
			
		||||
					setting.AppSubURL,
 | 
			
		||||
					strings.TrimSuffix(ctx.Req.URL.String(), ctx.Params("*")),
 | 
			
		||||
					ctx.Repo.BranchNameSubURL(),
 | 
			
		||||
					ctx.Repo.TreePath))
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user