Handle an image ref with scheme

An image ref must be a scheme-less URI. A reference with scheme (such
as `http://`) must return ErrInvalid.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
Kazuyoshi Kato
2020-11-16 15:06:35 -08:00
parent cc3785c815
commit fd01744a0c
2 changed files with 4 additions and 6 deletions

View File

@@ -85,6 +85,10 @@ var splitRe = regexp.MustCompile(`[:@]`)
// Parse parses the string into a structured ref.
func Parse(s string) (Spec, error) {
if strings.Contains(s, "://") {
return Spec{}, ErrInvalid
}
u, err := url.Parse("dummy://" + s)
if err != nil {
return Spec{}, err