Skip to content

Commit

Permalink
feat!: replace regex package (close #5755)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Dec 31, 2023
1 parent 6b8f35e commit 478470f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/deckarep/golang-set/v2 v2.3.1
github.com/disintegration/imaging v1.6.2
github.com/djherbis/times v1.5.0
github.com/dlclark/regexp2 v1.10.0
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564
github.com/foxxorcat/mopan-sdk-go v0.1.4
github.com/foxxorcat/weiyun-sdk-go v0.1.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/djherbis/times v1.5.0 h1:79myA211VwPhFTqUk8xehWrsEO+zcIZj0zT8mXPVARU=
github.com/djherbis/times v1.5.0/go.mod h1:5q7FDLvbNg1L/KaBmPcWlVR9NmoKo3+ucqUA3ijQhA0=
github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0=
github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 h1:I6KUy4CI6hHjqnyJLNCEi7YHVMkwwtfSr2k9splgdSM=
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564/go.mod h1:yekO+3ZShy19S+bsmnERmznGy9Rfg6dWWWpiGJjNAz8=
github.com/foxxorcat/mopan-sdk-go v0.1.4 h1:6utvPiBv8KDRDVKB7A4FERdrVxcHKZd2fBFCNuKcXzU=
Expand Down
10 changes: 5 additions & 5 deletions internal/model/obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package model

import (
"io"
"regexp"
"sort"
"strings"
"time"

"github.com/alist-org/alist/v3/pkg/http_range"
"github.com/alist-org/alist/v3/pkg/utils"
"github.com/dlclark/regexp2"

mapset "github.com/deckarep/golang-set/v2"

Expand Down Expand Up @@ -169,7 +169,7 @@ func NewObjMerge() *ObjMerge {
}

type ObjMerge struct {
regs []*regexp.Regexp
regs []*regexp2.Regexp
set mapset.Set[string]
}

Expand All @@ -190,7 +190,7 @@ func (om *ObjMerge) insertObjs(objs []Obj, objs_ ...Obj) []Obj {

func (om *ObjMerge) clickObj(obj Obj) bool {
for _, reg := range om.regs {
if reg.MatchString(obj.GetName()) {
if isMatch, _ := reg.MatchString(obj.GetName()); isMatch {
return false
}
}
Expand All @@ -199,9 +199,9 @@ func (om *ObjMerge) clickObj(obj Obj) bool {

func (om *ObjMerge) InitHideReg(hides string) {
rs := strings.Split(hides, "\n")
om.regs = make([]*regexp.Regexp, 0, len(rs))
om.regs = make([]*regexp2.Regexp, 0, len(rs))
for _, r := range rs {
om.regs = append(om.regs, regexp.MustCompile(r))
om.regs = append(om.regs, regexp2.MustCompile(r, regexp2.None))
}
}

Expand Down

0 comments on commit 478470f

Please sign in to comment.