mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Do not add prefix on http/https submodule links (#12477)
Fix #12345 Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
		@@ -97,13 +97,13 @@ func getRefURL(refURL, urlPrefix, repoFullName string) string {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	for _, scheme := range supportedSchemes {
 | 
						for _, scheme := range supportedSchemes {
 | 
				
			||||||
		if ref.Scheme == scheme {
 | 
							if ref.Scheme == scheme {
 | 
				
			||||||
			if urlPrefixHostname == refHostname {
 | 
								if ref.Scheme == "http" || ref.Scheme == "https" {
 | 
				
			||||||
				return urlPrefix + path.Clean(path.Join("/", ref.Path))
 | 
					 | 
				
			||||||
			} else if ref.Scheme == "http" || ref.Scheme == "https" {
 | 
					 | 
				
			||||||
				if len(ref.User.Username()) > 0 {
 | 
									if len(ref.User.Username()) > 0 {
 | 
				
			||||||
					return ref.Scheme + "://" + fmt.Sprintf("%v", ref.User) + "@" + ref.Host + ref.Path
 | 
										return ref.Scheme + "://" + fmt.Sprintf("%v", ref.User) + "@" + ref.Host + ref.Path
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return ref.Scheme + "://" + ref.Host + ref.Path
 | 
									return ref.Scheme + "://" + ref.Host + ref.Path
 | 
				
			||||||
 | 
								} else if urlPrefixHostname == refHostname {
 | 
				
			||||||
 | 
									return urlPrefix + path.Clean(path.Join("/", ref.Path))
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				return "http://" + refHostname + ref.Path
 | 
									return "http://" + refHostname + ref.Path
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@ func TestGetRefURL(t *testing.T) {
 | 
				
			|||||||
		{"git://git@try.gitea.io:9999/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "https://try.gitea.io/go-gitea/gitea"},
 | 
							{"git://git@try.gitea.io:9999/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "https://try.gitea.io/go-gitea/gitea"},
 | 
				
			||||||
		{"ssh://git@127.0.0.1:9999/go-gitea/gitea", "https://127.0.0.1:3000/", "go-gitea/sdk", "https://127.0.0.1:3000/go-gitea/gitea"},
 | 
							{"ssh://git@127.0.0.1:9999/go-gitea/gitea", "https://127.0.0.1:3000/", "go-gitea/sdk", "https://127.0.0.1:3000/go-gitea/gitea"},
 | 
				
			||||||
		{"https://gitea.com:3000/user1/repo1.git", "https://127.0.0.1:3000/", "user/repo2", "https://gitea.com:3000/user1/repo1"},
 | 
							{"https://gitea.com:3000/user1/repo1.git", "https://127.0.0.1:3000/", "user/repo2", "https://gitea.com:3000/user1/repo1"},
 | 
				
			||||||
 | 
							{"https://example.gitea.com/gitea/user1/repo1.git", "https://example.gitea.com/gitea/", "user/repo2", "https://example.gitea.com/gitea/user1/repo1"},
 | 
				
			||||||
		{"https://username:password@github.com/username/repository.git", "/", "username/repository2", "https://username:password@github.com/username/repository"},
 | 
							{"https://username:password@github.com/username/repository.git", "/", "username/repository2", "https://username:password@github.com/username/repository"},
 | 
				
			||||||
		{"somethingbad", "https://127.0.0.1:3000/go-gitea/gitea", "/", ""},
 | 
							{"somethingbad", "https://127.0.0.1:3000/go-gitea/gitea", "/", ""},
 | 
				
			||||||
		{"git@localhost:user/repo", "https://localhost/", "user2/repo1", "https://localhost/user/repo"},
 | 
							{"git@localhost:user/repo", "https://localhost/", "user2/repo1", "https://localhost/user/repo"},
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user