mirror of
https://github.com/gogs/gogs.git
synced 2026-05-07 00:07:02 +02:00
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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user