Skip to content

Commit

Permalink
πŸ› Fix trailing single asterisk matching subdirs
Browse files Browse the repository at this point in the history
This patch aims to prevent path patterns ending with `/*` from being
greedy and interpreted the same as `/**`. After applying it, that
trailing asterisk only matches one file or directory but not nested
ones.
  • Loading branch information
webknjaz committed Jul 11, 2023
1 parent 5e20ad6 commit 843dacf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion coverage/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def sep(s: str) -> str:
(r"\*\*+[^/]+", None), # Can't have **x
(r"\*\*/\*\*", None), # Can't have **/**
(r"^\*+/", r"(.*[/\\\\])?"), # ^*/ matches any prefix-slash, or nothing.
(r"/\*+$", r"[/\\\\].*"), # /*$ matches any slash-suffix.
(r"/\*\*+$", r"[/\\\\].*"), # /**$ matches any slash-suffix.
(r"\*\*/", r"(.*[/\\\\])?"), # **/ matches any subdirs, including none
(r"/", r"[/\\\\]"), # / matches either slash or backslash
(r"\*", r"[^/\\\\]*"), # * matches any number of non slash-likes
Expand Down

0 comments on commit 843dacf

Please sign in to comment.