Unverified Commit 0408205c authored by Blake Mizerany's avatar Blake Mizerany Committed by GitHub
Browse files

types/model: accept former `:` as a separator in digest (#3724)

This also converges the old sep `:` to the new sep `-`.
parent 63a7edd7
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{}
}
......
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