@@ -41,6 +41,7 @@ public class GlobMatcher : IEquatable<GlobMatcher>
4141
4242 private readonly GlobRegexItem [ ] [ ] _items ;
4343 private readonly bool _negate = false ;
44+ private readonly bool _allowDotMatch = false ;
4445 private readonly bool _ignoreCase = false ;
4546 #endregion
4647
@@ -54,6 +55,7 @@ public GlobMatcher(string pattern, GlobMatcherOptions options = DefaultOptions)
5455
5556 Options = options ;
5657 Raw = pattern ;
58+ _allowDotMatch = Options . HasFlag ( GlobMatcherOptions . AllowDotMatch ) ;
5759 _ignoreCase = Options . HasFlag ( GlobMatcherOptions . IgnoreCase ) ;
5860 _negate = ParseNegate ( ref pattern , Options ) ;
5961 _items = Compile ( pattern ) . ToArray ( ) ;
@@ -172,7 +174,7 @@ private GlobRegexItem ConvertSingleGlobPart(string globPart)
172174 // .abc will not be matched unless . is explicitly specified
173175 if ( globPart . Length > 0 && globPart [ 0 ] != '.' )
174176 {
175- patternStart = Options . HasFlag ( GlobMatcherOptions . AllowDotMatch ) ? PatternStartWithDotAllowed : PatternStartWithoutDotAllowed ;
177+ patternStart = _allowDotMatch ? PatternStartWithDotAllowed : PatternStartWithoutDotAllowed ;
176178 }
177179
178180 for ( int i = 0 ; i < globPart . Length ; i ++ )
@@ -295,7 +297,7 @@ private string GlobRegexItemToRegex(GlobRegexItem item)
295297 {
296298 return SingleStarToRegex ;
297299 }
298- if ( Options . HasFlag ( GlobMatcherOptions . AllowDotMatch ) )
300+ if ( _allowDotMatch )
299301 {
300302 // ** when dots are allowed, allows anything except .. and .
301303 // not (^ or / followed by one or two dots followed by $ or /)
@@ -385,7 +387,7 @@ private bool MatchOne(string[] fileParts, GlobRegexItem[] globParts, bool matchP
385387 break ;
386388 case GlobRegexItemType . PlainText :
387389 StringComparison comparison = StringComparison . Ordinal ;
388- if ( Options . HasFlag ( GlobMatcherOptions . IgnoreCase ) )
390+ if ( _ignoreCase )
389391 {
390392 comparison = StringComparison . OrdinalIgnoreCase ;
391393 }
@@ -408,7 +410,7 @@ private bool DisallowedMatchExists(string filePart)
408410 {
409411 if ( filePart == "."
410412 || filePart == ".."
411- || ( ! Options . HasFlag ( GlobMatcherOptions . AllowDotMatch ) && filePart . StartsWith ( "." , StringComparison . Ordinal ) ) )
413+ || ( ! _allowDotMatch && filePart . StartsWith ( "." , StringComparison . Ordinal ) ) )
412414 {
413415 return true ;
414416 }
0 commit comments