Skip to content

Commit

Permalink
fix: check empty registry name
Browse files Browse the repository at this point in the history
Signed-off-by: Shiwei Zhang <shizh@microsoft.com>
  • Loading branch information
shizhMSFT committed Mar 20, 2024
1 parent 4503c31 commit b94b39b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion registry/reference.go
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions registry/reference_test.go
Expand Up @@ -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",
Expand Down

0 comments on commit b94b39b

Please sign in to comment.