Files
photoprism/pkg/clean/version.go
2025-11-21 15:28:04 +01:00

25 lines
471 B
Go

package clean
import (
"fmt"
"regexp"
)
// VersionRegexp finds semantic version-like strings.
var VersionRegexp = regexp.MustCompile(`(\d+\.)(\d+\.)(\*|\d+)`)
// Version parses and returns a semantic version string.
func Version(s string) string {
if s == "" {
return ""
}
// Find version string with regular expression
// and return it with "v" prefix if found.
if v := VersionRegexp.FindString(s); v != "" {
return fmt.Sprintf("v%s", v)
}
return ""
}