From 9d31de2e0bc1053a3bab9cb27200e882bbb7004b Mon Sep 17 00:00:00 2001 From: Szekely Szabolcs Date: Tue, 16 Apr 2019 17:05:35 +0300 Subject: [PATCH] Compare file path with same separators Transform both file paths to have similar path delimiters before comparing them. Proposed solution to issue #54 --- src/FileMatchers/EndsWith.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/FileMatchers/EndsWith.php b/src/FileMatchers/EndsWith.php index c5e4260..22213c5 100644 --- a/src/FileMatchers/EndsWith.php +++ b/src/FileMatchers/EndsWith.php @@ -38,6 +38,9 @@ protected function fileEndsWith($haystack, $needle) return $this->fileEndsWith($needle, $haystack); } + $haystack = str_replace('\\', '/', $haystack); + $needle = str_replace('\\', '/', $needle); + return (substr($haystack, -$length) === $needle); } }