瀏覽代碼

types/model: fix name for hostport

Michael Yang 1 年之前
父節點
當前提交
8867e744ff
共有 2 個文件被更改,包括 13 次插入1 次删除
  1. 5 1
      types/model/name.go
  2. 8 0
      types/model/name_test.go

+ 5 - 1
types/model/name.go

@@ -143,7 +143,11 @@ func ParseNameBare(s string) Name {
 		n.RawDigest = MissingPart
 		n.RawDigest = MissingPart
 	}
 	}
 
 
-	s, n.Tag, _ = cutPromised(s, ":")
+	// "/" is an illegal tag character, so we can use it to split the host
+	if strings.LastIndex(s, ":") > strings.LastIndex(s, "/") {
+		s, n.Tag, _ = cutPromised(s, ":")
+	}
+
 	s, n.Model, promised = cutPromised(s, "/")
 	s, n.Model, promised = cutPromised(s, "/")
 	if !promised {
 	if !promised {
 		n.Model = s
 		n.Model = s

+ 8 - 0
types/model/name_test.go

@@ -34,6 +34,14 @@ func TestParseNameParts(t *testing.T) {
 				Model:     "model",
 				Model:     "model",
 			},
 			},
 		},
 		},
+		{
+			in: "host:12345/namespace/model",
+			want: Name{
+				Host:      "host:12345",
+				Namespace: "namespace",
+				Model:     "model",
+			},
+		},
 		{
 		{
 			in: "namespace/model",
 			in: "namespace/model",
 			want: Name{
 			want: Name{