X Tutup
Skip to content

Commit c240ab9

Browse files
committed
Unconditionally resolve "ssh.github.com" to "github.com"
Previously, only "github.com" mapped to "ssh.github.com" via ssh config was treated as "github.com". Now, any "ssh.github.com" host is treated as "github.com", even if it was initially aliased as something else in the user's ssh hostname mappings.
1 parent 0aaa334 commit c240ab9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

git/ssh_config.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ func (m SSHAliasMap) Translator() func(*url.URL) *url.URL {
3030
if !ok {
3131
return u
3232
}
33-
// FIXME: cleanup domain logic
34-
if strings.EqualFold(u.Hostname(), "github.com") && strings.EqualFold(resolvedHost, "ssh.github.com") {
35-
return u
33+
if strings.EqualFold(resolvedHost, "ssh.github.com") {
34+
resolvedHost = "github.com"
3635
}
3736
newURL, _ := url.Parse(u.String())
3837
newURL.Host = resolvedHost

git/ssh_config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,14 @@ func Test_Translator(t *testing.T) {
128128
m := SSHAliasMap{
129129
"gh": "github.com",
130130
"github.com": "ssh.github.com",
131+
"my.gh.com": "ssh.github.com",
131132
}
132133
tr := m.Translator()
133134

134135
cases := [][]string{
135136
{"ssh://gh/o/r", "ssh://github.com/o/r"},
136137
{"ssh://github.com/o/r", "ssh://github.com/o/r"},
138+
{"ssh://my.gh.com", "ssh://github.com"},
137139
{"https://gh/o/r", "https://gh/o/r"},
138140
}
139141
for _, c := range cases {

0 commit comments

Comments
 (0)
X Tutup