mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
24 lines
433 B
Go
24 lines
433 B
Go
package clean
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
)
|
|
|
|
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)
|
|
} else {
|
|
return ""
|
|
}
|
|
}
|