From 9f2d8d2117c141d28eabc284a482578d613d5a3c Mon Sep 17 00:00:00 2001 From: Blake Mizerany Date: Thu, 4 Apr 2024 00:11:31 -0700 Subject: [PATCH] ... --- x/build/blob/ref.go | 9 +++++++-- x/build/blob/ref_test.go | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/x/build/blob/ref.go b/x/build/blob/ref.go index 4685f433..c824391a 100644 --- a/x/build/blob/ref.go +++ b/x/build/blob/ref.go @@ -198,6 +198,11 @@ func ParseRef(s string) Ref { return r } +// Parts returns a sequence of the parts of a ref string from most specific +// to least specific. +// +// It normalizes the input string by removing "http://" and "https://" only. +// No other normalization is done. func Parts(s string) iter.Seq2[PartKind, string] { return func(yield func(PartKind, string) bool) { if strings.HasPrefix(s, "http://") { @@ -224,8 +229,7 @@ func Parts(s string) iter.Seq2[PartKind, string] { case '+': switch state { case Build: - v := strings.ToUpper(s[i+1 : j]) - if !yieldValid(Build, v) { + if !yieldValid(Build, s[i+1:j]) { return } state, j = Tag, i @@ -265,6 +269,7 @@ func Parts(s string) iter.Seq2[PartKind, string] { case Domain: yieldValid(Domain, s[:j]) case Namespace: + println("namespace", s[:j]) yieldValid(Namespace, s[:j]) default: yieldValid(Name, s[:j]) diff --git a/x/build/blob/ref_test.go b/x/build/blob/ref_test.go index 701f208d..533f5585 100644 --- a/x/build/blob/ref_test.go +++ b/x/build/blob/ref_test.go @@ -24,9 +24,9 @@ var testRefs = map[string]Ref{ // invalid "mistral:7b+Q4_0:latest": {}, "mi tral": {}, - - // From fuzzing - "/0": {}, + "x/y/z/foo": {}, + "/0": {}, + "0/": {}, } func TestRefParts(t *testing.T) {