Skip to content

Commit 60880cd

Browse files
committed
Fix path ignores not matching subdirs in URLs
Currently a pattern like /category/abc ignores subpaths such as /category/abc/def in files because of how we parse the filesystem. We ignore the entire dir and implicitly ignore its children. But when we match URL paths, we only match the entire path and don't consider if any of its parent "directories" are ignored. We want the ignore behavior for URL paths to be as close to filesystem behavior as we can get it. Fix by changing the /?$ part of the regex to (/.*)?$ so that each path ignore pattern matches all subpaths as well as the exact path itself.
1 parent a8fa649 commit 60880cd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/FileIgnorePattern.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ public function __construct(
5656
$this->regex = $regex . 'i';
5757

5858
// URL paths can match with or without trailing /
59+
// We add a .* to make directory patterns also match
60+
// child paths
5961
$url_regex = Pattern::make( $pattern )->toRegex( Pattern::START_ANCHOR );
60-
$this->url_regex = substr( $url_regex, 0, -1 ) . '/?$#i';
62+
$this->url_regex = substr( $url_regex, 0, -1 ) . '(/.*)?$#i';
6163
}
6264

6365
public function matches(

0 commit comments

Comments
 (0)