diff --git a/registry/reference.go b/registry/reference.go index 8fde0d22..fc3e95e5 100644 --- a/registry/reference.go +++ b/registry/reference.go @@ -192,7 +192,7 @@ func (r Reference) Validate() error { // ValidateRegistry validates the registry. func (r Reference) ValidateRegistry() error { - if uri, err := url.ParseRequestURI("dummy://" + r.Registry); err != nil || uri.Host != r.Registry { + if uri, err := url.ParseRequestURI("dummy://" + r.Registry); err != nil || uri.Host == "" || uri.Host != r.Registry { return fmt.Errorf("%w: invalid registry %q", errdef.ErrInvalidReference, r.Registry) } return nil diff --git a/registry/reference_test.go b/registry/reference_test.go index 20cab6b3..414b33bb 100644 --- a/registry/reference_test.go +++ b/registry/reference_test.go @@ -113,6 +113,10 @@ func TestParseReferenceUglies(t *testing.T) { name: "missing registry", raw: "hello-world:linux", }, + { + name: "missing registry (issue #698)", + raw: "/hello-world:linux", + }, { name: "invalid repo name", raw: "localhost/UPPERCASE/test",