Skip to content

Commit 74dfb17

Browse files
committed
Fix parse ssh with interface
1 parent ebd54a8 commit 74dfb17

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

modules/git/url/url.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func Parse(remote string) (*GitURL, error) {
6161
lastIndex = i + 1
6262
case ':':
6363
if !squareBrackets {
64-
url.Host = remote[lastIndex:i]
64+
url.Host = strings.Replace(remote[lastIndex:i], "%25", "%", -1)
6565
if len(remote) <= i+1 {
6666
return nil, ErrWrongURLFormat{URL: remote}
6767
}

modules/git/url/url_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestParseGitURLs(t *testing.T) {
3434
URL: &url.URL{
3535
Scheme: "ssh",
3636
User: url.User("git"),
37-
Host: "[fe80:14fc:cec5:c174:d88%2510]",
37+
Host: "[fe80:14fc:cec5:c174:d88%10]",
3838
Path: "go-gitea/gitea.git",
3939
},
4040
extraMark: 1,
@@ -131,6 +131,18 @@ func TestParseGitURLs(t *testing.T) {
131131
extraMark: 0,
132132
},
133133
},
134+
{
135+
kase: "https://[fe80:14fc:cec5:c174:d88%2510]:20/go-gitea/gitea.git",
136+
expected: &GitURL{
137+
URL: &url.URL{
138+
Scheme: "https",
139+
Host: "[fe80:14fc:cec5:c174:d88%10]:20",
140+
Path: "/go-gitea/gitea.git",
141+
},
142+
extraMark: 0,
143+
},
144+
},
145+
134146
{
135147
kase: "git://github.com/go-gitea/gitea.git",
136148
expected: &GitURL{

0 commit comments

Comments
 (0)