Skip to content

Commit

Permalink
types/model: accept former : as a separator in digest (ollama#3724)
Browse files Browse the repository at this point in the history
This also converges the old sep `:` to the new sep `-`.
  • Loading branch information
bmizerany authored Apr 18, 2024
1 parent 63a7edd commit 0408205
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion types/model/digest.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package model

import (
"fmt"
"log/slog"
"strings"
"unicode"
Expand Down Expand Up @@ -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{}
}
Expand Down

0 comments on commit 0408205

Please sign in to comment.