Skip to content

Commit be1b33c

Browse files
authored
Do not add prefix on http/https submodule links (#12477)
Fix #12345 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 4e1c7cc commit be1b33c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

modules/git/submodule.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ func getRefURL(refURL, urlPrefix, repoFullName string) string {
9797

9898
for _, scheme := range supportedSchemes {
9999
if ref.Scheme == scheme {
100-
if urlPrefixHostname == refHostname {
101-
return urlPrefix + path.Clean(path.Join("/", ref.Path))
102-
} else if ref.Scheme == "http" || ref.Scheme == "https" {
100+
if ref.Scheme == "http" || ref.Scheme == "https" {
103101
if len(ref.User.Username()) > 0 {
104102
return ref.Scheme + "://" + fmt.Sprintf("%v", ref.User) + "@" + ref.Host + ref.Path
105103
}
106104
return ref.Scheme + "://" + ref.Host + ref.Path
105+
} else if urlPrefixHostname == refHostname {
106+
return urlPrefix + path.Clean(path.Join("/", ref.Path))
107107
} else {
108108
return "http://" + refHostname + ref.Path
109109
}

modules/git/submodule_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func TestGetRefURL(t *testing.T) {
2828
{"git://[email protected]:9999/go-gitea/gitea", "https://try.gitea.io/", "go-gitea/sdk", "https://try.gitea.io/go-gitea/gitea"},
2929
{"ssh://[email protected]:9999/go-gitea/gitea", "https://127.0.0.1:3000/", "go-gitea/sdk", "https://127.0.0.1:3000/go-gitea/gitea"},
3030
{"https://gitea.com:3000/user1/repo1.git", "https://127.0.0.1:3000/", "user/repo2", "https://gitea.com:3000/user1/repo1"},
31+
{"https://example.gitea.com/gitea/user1/repo1.git", "https://example.gitea.com/gitea/", "user/repo2", "https://example.gitea.com/gitea/user1/repo1"},
3132
{"https://username:[email protected]/username/repository.git", "/", "username/repository2", "https://username:[email protected]/username/repository"},
3233
{"somethingbad", "https://127.0.0.1:3000/go-gitea/gitea", "/", ""},
3334
{"git@localhost:user/repo", "https://localhost/", "user2/repo1", "https://localhost/user/repo"},

0 commit comments

Comments
 (0)