Commit 88775e1f authored by Michael Yang's avatar Michael Yang
Browse files

strip scheme from name

parent 8867e744
...@@ -153,12 +153,18 @@ func ParseNameBare(s string) Name { ...@@ -153,12 +153,18 @@ func ParseNameBare(s string) Name {
n.Model = s n.Model = s
return n return n
} }
s, n.Namespace, promised = cutPromised(s, "/") s, n.Namespace, promised = cutPromised(s, "/")
if !promised { if !promised {
n.Namespace = s n.Namespace = s
return n return n
} }
n.Host = s
scheme, host, ok := strings.Cut(s, "://")
if ! ok {
host = scheme
}
n.Host = host
return n return n
} }
......
...@@ -17,6 +17,15 @@ func TestParseNameParts(t *testing.T) { ...@@ -17,6 +17,15 @@ func TestParseNameParts(t *testing.T) {
want Name want Name
wantValidDigest bool wantValidDigest bool
}{ }{
{
in: "scheme://host:port/namespace/model:tag",
want: Name{
Host: "host:port",
Namespace: "namespace",
Model: "model",
Tag: "tag",
},
},
{ {
in: "host/namespace/model:tag", in: "host/namespace/model:tag",
want: Name{ want: Name{
...@@ -26,6 +35,15 @@ func TestParseNameParts(t *testing.T) { ...@@ -26,6 +35,15 @@ func TestParseNameParts(t *testing.T) {
Tag: "tag", Tag: "tag",
}, },
}, },
{
in: "host:port/namespace/model:tag",
want: Name{
Host: "host:port",
Namespace: "namespace",
Model: "model",
Tag: "tag",
},
},
{ {
in: "host/namespace/model", in: "host/namespace/model",
want: Name{ want: Name{
...@@ -35,9 +53,9 @@ func TestParseNameParts(t *testing.T) { ...@@ -35,9 +53,9 @@ func TestParseNameParts(t *testing.T) {
}, },
}, },
{ {
in: "host:12345/namespace/model", in: "host:port/namespace/model",
want: Name{ want: Name{
Host: "host:12345", Host: "host:port",
Namespace: "namespace", Namespace: "namespace",
Model: "model", Model: "model",
}, },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment