Skip to content

Commit

Permalink
Fix for slash (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
elifarley authored Dec 20, 2024
1 parent 03a0c92 commit adec8f7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gitignore_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,21 @@ def fnmatch_pathname_to_regex(
res.append('[{}]'.format(stuff))
else:
res.append(re.escape(c))

if anchored:
res.insert(0, '^')
else:
res.insert(0, f"(^|{seps_group})")
if not directory_only:

if directory_only and not pattern.endswith('/'):
res.append(f"($|{seps_group}.*)")
elif not directory_only:
res.append('$')
elif directory_only and negation:
res.append('/$')
else:
res.append('($|\\/)')

return ''.join(res)


Expand Down

0 comments on commit adec8f7

Please sign in to comment.