File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ class FileIgnorePattern {
1919 */
2020 private $ regex ;
2121
22+ /**
23+ * @var string
24+ * Regex tested against relative URLs.
25+ */
26+ private $ url_regex ;
27+
2228 /**
2329 * Following gitignore rules:
2430 * - Patterns ending in / match only directories.
@@ -49,7 +55,9 @@ public function __construct(
4955 // Make it case-insensitive
5056 $ this ->regex = $ regex . 'i ' ;
5157
52- // WsLog::l("Created regex $this->regex for pattern $pattern");
58+ // URL paths can match with or without trailing /
59+ $ url_regex = Pattern::make ( $ pattern )->toRegex ( Pattern::START_ANCHOR );
60+ $ this ->url_regex = substr ( $ url_regex , 0 , -1 ) . '/?$#i ' ;
5361 }
5462
5563 public function matches (
@@ -69,8 +77,8 @@ public function matches(
6977 public function matchesPath (
7078 string $ path ,
7179 ): bool {
72- if ( preg_match ( $ this ->regex , $ path ) ) {
73- WsLog::d ( "Ignoring $ path with regex $ this ->regex " );
80+ if ( preg_match ( $ this ->url_regex , $ path ) ) {
81+ WsLog::d ( "Ignoring $ path with regex $ this ->url_regex " );
7482 return true ;
7583 }
7684
You can’t perform that action at this time.
0 commit comments