Merge pull request #30909 from jinjiadu/main

refactor: replace HasPrefix+TrimPrefix with CutPrefix
pull/30955/head
Robert Sirchia 4 months ago committed by GitHub
commit c0aa690c90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -170,10 +170,10 @@ func (r *Rules) parseRule(rule string) error {
rule = strings.TrimSuffix(rule, "/")
}
if strings.HasPrefix(rule, "/") {
if after, ok := strings.CutPrefix(rule, "/"); ok {
// Require path matches the root path.
p.match = func(n string, _ os.FileInfo) bool {
rule = strings.TrimPrefix(rule, "/")
rule = after
ok, err := filepath.Match(rule, n)
if err != nil {
slog.Error("failed to compile", "rule", rule, slog.Any("error", err))

Loading…
Cancel
Save