Skip to content

Commit fd01744

Browse files
author
Kazuyoshi Kato
committed
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 <[email protected]>
1 parent cc3785c commit fd01744

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

reference/reference.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ var splitRe = regexp.MustCompile(`[:@]`)
8585

8686
// Parse parses the string into a structured ref.
8787
func Parse(s string) (Spec, error) {
88+
if strings.Contains(s, "://") {
89+
return Spec{}, ErrInvalid
90+
}
91+
8892
u, err := url.Parse("dummy://" + s)
8993
if err != nil {
9094
return Spec{}, err

reference/reference_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ func TestReferenceParser(t *testing.T) {
151151
},
152152
},
153153
{
154-
Skip: true, // TODO(stevvooe): Implement this case.
155154
Name: "SchemeDefined",
156155
Input: "http://xn--7o8h.com/myimage:xn--7o8h.com@sha512:fffffff",
157156
Hostname: "xn--7o8h.com",
@@ -160,11 +159,6 @@ func TestReferenceParser(t *testing.T) {
160159
},
161160
} {
162161
t.Run(testcase.Name, func(t *testing.T) {
163-
if testcase.Skip {
164-
t.Skip("testcase disabled")
165-
return
166-
}
167-
168162
ref, err := Parse(testcase.Input)
169163
if err != testcase.Err {
170164
if testcase.Err != nil {

0 commit comments

Comments
 (0)