Prepare regexps on compile time (#1327)

This commit is contained in:
Yury Gargay
2023-11-27 13:01:00 +01:00
committed by GitHub
parent 0ca06b566a
commit 63d211c698
7 changed files with 24 additions and 26 deletions

View File

@@ -7,7 +7,6 @@ import (
"fmt"
"io"
"net/http"
"regexp"
"sort"
"strings"
"time"
@@ -381,15 +380,10 @@ func createPostRequest(ctx context.Context, endpoint string, payloadStr string)
}
func getMinMaxVersion(inputList []string) (string, string) {
reg, err := regexp.Compile(version.SemverRegexpRaw)
if err != nil {
return "", ""
}
versions := make([]*version.Version, 0)
for _, raw := range inputList {
if raw != "" && reg.MatchString(raw) {
if raw != "" && nbversion.SemverRegexp.MatchString(raw) {
v, err := version.NewVersion(raw)
if err == nil {
versions = append(versions, v)