Skip to content

Commit f28365b

Browse files
Copilotswissspidy
andcommitted
Improve path matching with regex for better robustness
Co-authored-by: swissspidy <[email protected]>
1 parent dd22d61 commit f28365b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Find_Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ private function recurse_directory( $path ) {
244244
return;
245245
}
246246
foreach ( $this->ignored_paths as $ignored_path ) {
247-
// Match at directory boundaries: either at the start or after a directory separator
248-
if ( 0 === stripos( $compared_path, $ignored_path ) || false !== stripos( $compared_path, '/' . $ignored_path ) ) {
247+
// Match at directory boundaries using regex to ensure we match complete directory names
248+
if ( preg_match( '#(^|/)' . preg_quote( $ignored_path, '#' ) . '#i', $compared_path ) ) {
249249
$this->log( "Matched ignored path. Skipping recursion into '{$path}'" );
250250
return;
251251
}

0 commit comments

Comments
 (0)