Skip to content

Commit

Permalink
Fixed bug #3007: Directory exclude pattern improperly excludes direct…
Browse files Browse the repository at this point in the history
…ories with names that start the same
  • Loading branch information
Steve Talbot authored and gsherwood committed Sep 1, 2020
1 parent 891675e commit 5a6b63d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Filters/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ protected function shouldIgnorePath($path)
// Need to check this pattern for dirs as well as individual file paths.
$this->ignoreFilePatterns[$pattern] = $type;

$pattern = substr($pattern, 0, -2);
$pattern = substr($pattern, 0, -2).'(?=/|$)';
$this->ignoreDirPatterns[$pattern] = $type;
} else {
// This is a file-specific pattern, so only need to check this
Expand Down
6 changes: 5 additions & 1 deletion tests/Core/Filters/Filter/AcceptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ public function dataExcludePatterns()
'/path/to/src/Main.php',
'/path/to/src/Something/Main.php',
'/path/to/src/Somethingelse/Main.php',
'/path/to/src/SomethingelseEvenLonger/Main.php',
'/path/to/src/Other/Main.php',
],
['/path/to/src/Main.php'],
[
'/path/to/src/Main.php',
'/path/to/src/SomethingelseEvenLonger/Main.php',
],
],

// Test ignoring standard/sniff specific exclude patterns.
Expand Down

0 comments on commit 5a6b63d

Please sign in to comment.