@@ -126,13 +126,14 @@ def __repr__(self):
126126 def match (self , abs_path : Union [str , Path ]):
127127 matched = False
128128 if self .base_path :
129- rel_path = str ( _normalize_path (abs_path ).relative_to (self .base_path ))
129+ rel_path = _normalize_path (abs_path ).relative_to (self .base_path ). as_posix ( )
130130 else :
131- rel_path = str ( _normalize_path (abs_path ))
132- # Path() strips the trailing whitespace on windows, so we need to
133- # preserve it.
131+ rel_path = _normalize_path (abs_path ). as_posix ( )
132+ # Path() strips the trailing following symbols on windows, so we need to
133+ # preserve it: ' ', '.'
134134 if sys .platform .startswith ('win' ):
135- rel_path += ' ' * _count_trailing_whitespace (abs_path )
135+ rel_path += ' ' * _count_trailing_symbol (' ' , abs_path )
136+ rel_path += '.' * _count_trailing_symbol ('.' , abs_path )
136137 # Path() strips the trailing slash, so we need to preserve it
137138 # in case of directory-only negation
138139 if self .negation and type (abs_path ) == str and abs_path [- 1 ] == '/' :
@@ -225,11 +226,11 @@ def _normalize_path(path: Union[str, Path]) -> Path:
225226 return Path (abspath (path ))
226227
227228
228- def _count_trailing_whitespace ( text : str ) -> int :
229- """Count the number of trailing whitespace characters in a string."""
229+ def _count_trailing_symbol ( symbol : str , text : str ) -> int :
230+ """Count the number of trailing characters in a string."""
230231 count = 0
231232 for char in reversed (str (text )):
232- if char . isspace () :
233+ if char == symbol :
233234 count += 1
234235 else :
235236 break
0 commit comments