github: use regexp2 for advanced regex

Signed-off-by: unilock <unilock@fennet.rentals>
This commit is contained in:
unilock
2024-04-16 07:04:13 -04:00
parent 979b606b1e
commit 7207d4c6a4
4 changed files with 11 additions and 5 deletions

View File

@@ -3,9 +3,9 @@ package github
import (
"errors"
"fmt"
"regexp"
"strings"
"github.com/dlclark/regexp2"
"github.com/mitchellh/mapstructure"
"github.com/packwiz/packwiz/core"
)
@@ -53,7 +53,7 @@ func (u ghUpdater) CheckUpdate(mods []*core.Mod, pack core.Pack) ([]core.UpdateC
continue
}
expr := regexp.MustCompile(data.Regex)
expr := regexp2.MustCompile(data.Regex, 0)
if len(newRelease.Assets) == 0 {
results[i] = core.UpdateCheck{Error: errors.New("new release doesn't have any assets")}
@@ -63,7 +63,8 @@ func (u ghUpdater) CheckUpdate(mods []*core.Mod, pack core.Pack) ([]core.UpdateC
var newFiles []Asset
for _, v := range newRelease.Assets {
if expr.MatchString(v.Name) {
bl, _ := expr.MatchString(v.Name)
if bl {
newFiles = append(newFiles, v)
}
}