From 0408205c1cb0d5af1ba97c08b9a24ddc41557097 Mon Sep 17 00:00:00 2001 From: Blake Mizerany Date: Thu, 18 Apr 2024 14:17:46 -0700 Subject: [PATCH] types/model: accept former `:` as a separator in digest (#3724) This also converges the old sep `:` to the new sep `-`. --- types/model/digest.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/model/digest.go b/types/model/digest.go index d5a7a155..d908fa02 100644 --- a/types/model/digest.go +++ b/types/model/digest.go @@ -1,6 +1,7 @@ package model import ( + "fmt" "log/slog" "strings" "unicode" @@ -47,8 +48,11 @@ var ( // Digest. func ParseDigest(s string) Digest { typ, digest, ok := strings.Cut(s, "-") + if !ok { + typ, digest, ok = strings.Cut(s, ":") + } if ok && isValidDigestType(typ) && isValidHex(digest) { - return Digest{s: s} + return Digest{s: fmt.Sprintf("%s-%s", typ, digest)} } return Digest{} }