diff --git a/pkg/ignore/rules.go b/pkg/ignore/rules.go index 5281c3d59..3511c2d40 100644 --- a/pkg/ignore/rules.go +++ b/pkg/ignore/rules.go @@ -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))