diff --git a/internal/filter/exclude.go b/internal/filter/exclude.go index 48ecdfddf..1d3042a58 100644 --- a/internal/filter/exclude.go +++ b/internal/filter/exclude.go @@ -39,11 +39,12 @@ func RejectByPattern(patterns []string, warnf func(msg string, args ...interface // RejectByInsensitivePattern is like RejectByPattern but case insensitive. func RejectByInsensitivePattern(patterns []string, warnf func(msg string, args ...interface{})) RejectByNameFunc { + lowerPatterns := make([]string, len(patterns)) for index, path := range patterns { - patterns[index] = strings.ToLower(path) + lowerPatterns[index] = strings.ToLower(path) } - rejFunc := RejectByPattern(patterns, warnf) + rejFunc := RejectByPattern(lowerPatterns, warnf) return func(item string) bool { return rejFunc(strings.ToLower(item)) } diff --git a/internal/filter/include.go b/internal/filter/include.go index e6eefe6b9..749139f6e 100644 --- a/internal/filter/include.go +++ b/internal/filter/include.go @@ -92,11 +92,12 @@ func IncludeByPattern(patterns []string, warnf func(msg string, args ...interfac // IncludeByInsensitivePattern returns a IncludeByNameFunc which includes files that match // one of the patterns, ignoring the casing of the filenames. func IncludeByInsensitivePattern(patterns []string, warnf func(msg string, args ...interface{})) IncludeByNameFunc { + lowerPatterns := make([]string, len(patterns)) for index, path := range patterns { - patterns[index] = strings.ToLower(path) + lowerPatterns[index] = strings.ToLower(path) } - includeFunc := IncludeByPattern(patterns, warnf) + includeFunc := IncludeByPattern(lowerPatterns, warnf) return func(item string) (matched bool, childMayMatch bool) { return includeFunc(strings.ToLower(item)) }