Skip to content

Commit

Permalink
Unconditionally resolve "ssh.github.com" to "github.com" (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
samcoe authored Aug 25, 2022
1 parent 3630ab3 commit 34c1b91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func NewTranslator() Translator {
for _, file := range configFiles {
_ = p.read(file)
}

return p.cfg
}

Expand All @@ -75,8 +76,8 @@ func (c config) Translate(u *url.URL) *url.URL {
if !ok {
return u
}
if strings.EqualFold(u.Hostname(), "github.com") && strings.EqualFold(resolvedHost, "ssh.github.com") {
return u
if strings.EqualFold(resolvedHost, "ssh.github.com") {
resolvedHost = "github.com"
}
newURL, _ := url.Parse(u.String())
newURL.Host = resolvedHost
Expand Down
2 changes: 2 additions & 0 deletions pkg/ssh/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,14 @@ func Test_Translate(t *testing.T) {
aliases: map[string]string{
"gh": "github.com",
"github.com": "ssh.github.com",
"my.gh.com": "ssh.github.com",
},
}

cases := [][]string{
{"ssh://gh/o/r", "ssh://github.com/o/r"},
{"ssh://github.com/o/r", "ssh://github.com/o/r"},
{"ssh://my.gh.com", "ssh://github.com"},
{"https://gh/o/r", "https://gh/o/r"},
}

Expand Down

0 comments on commit 34c1b91

Please sign in to comment.