@@ -2,6 +2,7 @@ package readers
22
33import (
44 "path/filepath"
5+ "strings"
56
67 "github.com/bmatcuk/doublestar/v4"
78
@@ -14,23 +15,31 @@ type exclusionMatcher struct {
1415 Exclusions []string
1516}
1617
18+ func normalizeGlobCandidate (value string ) string {
19+ return strings .ReplaceAll (value , "\\ " , "/" )
20+ }
21+
1722func newPathExclusionMatcher (exclusions []string ) * exclusionMatcher {
1823 return & exclusionMatcher {
1924 Exclusions : exclusions ,
2025 }
2126}
2227
2328func (ex * exclusionMatcher ) Match (term string ) bool {
29+ normalizedTerm := normalizeGlobCandidate (term )
30+
2431 for _ , exclusionPattern := range ex .Exclusions {
32+ normalizedPattern := normalizeGlobCandidate (exclusionPattern )
33+
2534 // Try matching in current form first
26- if m , err := doublestar .Match (exclusionPattern , term ); err == nil && m {
35+ if m , err := doublestar .Match (normalizedPattern , normalizedTerm ); err == nil && m {
2736 return true
2837 }
2938
3039 // If term is relative and pattern is absolute, convert term to absolute
3140 if ! filepath .IsAbs (term ) && filepath .IsAbs (exclusionPattern ) {
3241 if abs , err := filepath .Abs (term ); err == nil {
33- if m , err := doublestar .Match (exclusionPattern , abs ); err == nil && m {
42+ if m , err := doublestar .Match (normalizedPattern , normalizeGlobCandidate ( abs ) ); err == nil && m {
3443 return true
3544 }
3645 }
@@ -39,7 +48,7 @@ func (ex *exclusionMatcher) Match(term string) bool {
3948 // If term is absolute and pattern is relative, convert pattern to absolute
4049 if filepath .IsAbs (term ) && ! filepath .IsAbs (exclusionPattern ) {
4150 if abs , err := filepath .Abs (exclusionPattern ); err == nil {
42- if m , err := doublestar .Match (abs , term ); err == nil && m {
51+ if m , err := doublestar .Match (normalizeGlobCandidate ( abs ), normalizedTerm ); err == nil && m {
4352 return true
4453 }
4554 }
0 commit comments