python-pathspec
python-pathspec copied to clipboard
Leading & trailing whitespace
Hello, I am using this library and noticing some odd results around white space. When the white space is leading or trailing, I do not get any matches.
# Leading whitespace does not match
>>> pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern, [' whitespace.txt']).match_file(' whitespace.txt')
False
# Trailing whitespace does not match
>>> pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern, ['whitespace.txt ']).match_file('whitespace.txt ')
False
It seems to have no problem with whitespace internal to a string.
>>> pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern, ['white space.txt']).match_file('white space.txt')
True
Can you help me understand what is going on here? Both whitespace.txt
and whitespace.txt
are valid file names so I would like to figure out why I can't match them.