gitutil: strip SSH port from submodule URL when rendering for HTML link (#7383)

Co-authored-by: Joe Chen <jc@unknwon.io>
This commit is contained in:
TheDarkUndoing
2023-03-05 07:00:56 -05:00
committed by GitHub
parent 6fa552994a
commit 5483d97f73
6 changed files with 9 additions and 5 deletions

View File

@@ -50,7 +50,7 @@ func InferSubmoduleURL(baseURL string, mod *git.Submodule) string {
case "http", "https":
raw = parsed.String()
case "ssh":
raw = fmt.Sprintf("http://%s%s", parsed.Host, parsed.Path)
raw = fmt.Sprintf("http://%s%s", parsed.Hostname(), parsed.Path)
default:
return raw
}

View File

@@ -31,7 +31,7 @@ func TestInferSubmoduleURL(t *testing.T) {
URL: "ssh://user@github.com:22/gogs/docs-api.git",
Commit: "6b08f76a5313fa3d26859515b30aa17a5faa2807",
},
expURL: "http://github.com:22/gogs/docs-api/commit/6b08f76a5313fa3d26859515b30aa17a5faa2807",
expURL: "http://github.com/gogs/docs-api/commit/6b08f76a5313fa3d26859515b30aa17a5faa2807",
},
{
name: "SSH URL in SCP syntax",