diff --git a/util/sshutil/transport_validation.go b/util/sshutil/transport_validation.go index f00a1df2..598afac7 100644 --- a/util/sshutil/transport_validation.go +++ b/util/sshutil/transport_validation.go @@ -2,10 +2,17 @@ package sshutil import ( "regexp" + "strings" ) var gitSSHRegex = regexp.MustCompile("^[a-zA-Z0-9-_]+@[a-zA-Z0-9-.]+:.*$") func IsSSHTransport(s string) bool { + // check for explicit ssh transport + if strings.HasPrefix(s, "ssh://") { + return true + } + + // check for implicit ssh transport return gitSSHRegex.MatchString(s) } diff --git a/util/sshutil/transport_validation_test.go b/util/sshutil/transport_validation_test.go index 0f8ade57..546986dd 100644 --- a/util/sshutil/transport_validation_test.go +++ b/util/sshutil/transport_validation_test.go @@ -20,4 +20,5 @@ func TestIsSSHTransport(t *testing.T) { require.True(t, IsSSHTransport("other_Funky-username52@example.com:path/to/repo.git/")) require.True(t, IsSSHTransport("other_Funky-username52@example.com:/to/really:odd:repo.git/")) require.True(t, IsSSHTransport("teddy@4houses-down.com:/~/catnip.git/")) + require.True(t, IsSSHTransport("ssh://root@subdomain.example.hostname:2222/root/my/really/weird/path/foo.git")) }