Fix 'tcp+tls' protocol not being accepted

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2016-02-08 17:29:01 +00:00
parent 80e2b1b5e2
commit a830282265
2 changed files with 16 additions and 2 deletions

View file

@ -11,7 +11,7 @@ var (
validPrefixes = map[string][]string{ validPrefixes = map[string][]string{
"url": {"http://", "https://"}, "url": {"http://", "https://"},
"git": {"git://", "github.com/", "git@"}, "git": {"git://", "github.com/", "git@"},
"transport": {"tcp://", "udp://", "unix://"}, "transport": {"tcp://", "tcp+tls://", "udp://", "unix://"},
} }
urlPathWithFragmentSuffix = regexp.MustCompile(".git(?:#.+)?$") urlPathWithFragmentSuffix = regexp.MustCompile(".git(?:#.+)?$")
) )
@ -35,7 +35,7 @@ func IsGitTransport(str string) bool {
return IsURL(str) || strings.HasPrefix(str, "git://") || strings.HasPrefix(str, "git@") return IsURL(str) || strings.HasPrefix(str, "git://") || strings.HasPrefix(str, "git@")
} }
// IsTransportURL returns true if the provided str is a transport (tcp, udp, unix) URL. // IsTransportURL returns true if the provided str is a transport (tcp, tcp+tls, udp, unix) URL.
func IsTransportURL(str string) bool { func IsTransportURL(str string) bool {
return checkURL(str, "transport") return checkURL(str, "transport")
} }

View file

@ -18,6 +18,12 @@ var (
invalidGitUrls = []string{ invalidGitUrls = []string{
"http://github.com/docker/docker.git:#branch", "http://github.com/docker/docker.git:#branch",
} }
transportUrls = []string{
"tcp://example.com",
"tcp+tls://example.com",
"udp://example.com",
"unix:///example",
}
) )
func TestValidGitTransport(t *testing.T) { func TestValidGitTransport(t *testing.T) {
@ -53,3 +59,11 @@ func TestIsGIT(t *testing.T) {
} }
} }
} }
func TestIsTransport(t *testing.T) {
for _, url := range transportUrls {
if IsTransportURL(url) == false {
t.Fatalf("%q should be detected as valid Transport url", url)
}
}
}