mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-11 16:24:11 +01:00
25 lines
471 B
Go
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 ""
|
|
}
|