Skip to content

Commit

Permalink
Avoid error.
Browse files Browse the repository at this point in the history
  • Loading branch information
excitoon committed Aug 26, 2022
1 parent 02fd958 commit b38c5eb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gitignore_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ def rule_from_pattern(pattern, base_path=None, source=None):
# A slash is a sign that we're tied to the base_path of our rule
# set.
anchored = '/' in pattern[:-1]
if pattern[0] == '/':
if pattern[:1] == '/':
pattern = pattern[1:]
if pattern[0] == '*' and len(pattern) >= 2 and pattern[1] == '*':
if pattern[:2] == '**':
pattern = pattern[2:]
anchored = False
if pattern[0] == '/':
if pattern[:1] == '/':
pattern = pattern[1:]
if pattern[-1] == '/':
if pattern[-1:] == '/':
pattern = pattern[:-1]
# patterns with leading hashes are escaped with a backslash in front, unescape it
if pattern[0] == '\\' and pattern[1] == '#':
if pattern[:2] == '\\#':
pattern = pattern[1:]
# trailing spaces are ignored unless they are escaped with a backslash
i = len(pattern)-1
Expand Down

0 comments on commit b38c5eb

Please sign in to comment.