Merge pull request #2979 from avtakkar/avtakkar/fix-domain-split
Fix bug in parsing domain from repository reference
This commit is contained in:
commit
90e62ac24c
@ -89,7 +89,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:]
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user