trim non-numeric for debian packages

This commit is contained in:
Jeff Carr 2024-03-02 17:18:50 -06:00
parent de662f3b18
commit eebdaaf357
2 changed files with 21 additions and 1 deletions

View File

@ -1,6 +1,8 @@
package repolist package repolist
import ( import (
"unicode"
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/gui/repostatus" "go.wit.com/lib/gui/repostatus"
"go.wit.com/log" "go.wit.com/log"
@ -176,3 +178,21 @@ func (rl *RepoList) TotalGo() int {
} }
return count return count
} }
func trimNonNumericFromStart(s string) string {
for i, r := range s {
if unicode.IsDigit(r) {
return s[i:]
}
}
return ""
}
func ValidDebianPackageVersion(v string) string {
newv := trimNonNumericFromStart(v)
if newv == "" {
newv = "0.0"
}
log.Info("ValidDebianPackageVersion:", newv)
return newv
}

View File

@ -7,8 +7,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"go.wit.com/log"
"go.wit.com/lib/gui/repostatus" "go.wit.com/lib/gui/repostatus"
"go.wit.com/log"
) )
func (r *RepoList) RegisterHideFunction(f func(*RepoRow)) { func (r *RepoList) RegisterHideFunction(f func(*RepoRow)) {