From a19e1847a3a815894bdc9ffdc064392c96fa38c6 Mon Sep 17 00:00:00 2001 From: Aviral Takkar Date: Wed, 14 Aug 2019 15:27:59 -0700 Subject: [PATCH] Fix bug in parsing domain from repository reference Signed-off-by: Aviral Takkar --- reference/normalize.go | 2 +- reference/normalize_test.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/reference/normalize.go b/reference/normalize.go index b3dfb7a6d..128a1c731 100644 --- a/reference/normalize.go +++ b/reference/normalize.go @@ -90,7 +90,7 @@ func ParseDockerRef(ref string) (Named, error) { // needs to be already validated before. func splitDockerDomain(name string) (domain, remainder string) { i := strings.IndexRune(name, '/') - if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost") { + if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost" && strings.ToLower(name[:i]) == name[:i]) { domain, remainder = defaultDomain, name } else { domain, remainder = name[:i], name[i+1:] diff --git a/reference/normalize_test.go b/reference/normalize_test.go index a636236ee..fe5035e11 100644 --- a/reference/normalize_test.go +++ b/reference/normalize_test.go @@ -28,6 +28,8 @@ func TestValidateReferenceName(t *testing.T) { // when specified with a hostname, it removes the ambiguity from about // whether the value is an identifier or repository name "docker.io/1a3f5e7d9c1b3a5f7e9d1c3b5a7f9e1d3c5b7a9f1e3d5d7c9b1a3f5e7d9c1b3a", + "Docker/docker", + "DOCKER/docker", } invalidRepoNames := []string{ "https://github.com/docker/docker", @@ -229,6 +231,20 @@ func TestParseRepositoryInfo(t *testing.T) { AmbiguousName: "", Domain: "docker.io", }, + { + RemoteName: "bar", + FamiliarName: "Foo/bar", + FullName: "Foo/bar", + AmbiguousName: "", + Domain: "Foo", + }, + { + RemoteName: "bar", + FamiliarName: "FOO/bar", + FullName: "FOO/bar", + AmbiguousName: "", + Domain: "FOO", + }, } for _, tcase := range tcases {