Don't lower case case-insensitive patterns in place

This commit is contained in:
Michael Eischer
2026-05-16 15:28:51 +02:00
parent c04a1d857d
commit 3cc592463f
2 changed files with 6 additions and 4 deletions
+3 -2
View File
@@ -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))
}
+3 -2
View File
@@ -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))
}