From 4665b7376be87719fb5b3e1ab9211e1c88dab880 Mon Sep 17 00:00:00 2001 From: Luca Bognolo <11542801+BoGnY@users.noreply.github.com> Date: Wed, 27 Sep 2023 10:43:57 +0200 Subject: [PATCH] Fix directory separation problems on Windows machine --- src/Differ/PatchDiffer.php | 2 +- src/FileSystem/PathResolver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Differ/PatchDiffer.php b/src/Differ/PatchDiffer.php index 204295e9..33ecb213 100644 --- a/src/Differ/PatchDiffer.php +++ b/src/Differ/PatchDiffer.php @@ -50,7 +50,7 @@ public function diff(OldAndNewFile $oldAndNewFile): string private function resolveRelativeFilePath(string $beforeFilePath): string { - $match = Strings::match($beforeFilePath, self::LOCAL_PATH_REGEX); + $match = Strings::match(str_replace('\\', '/', $beforeFilePath), self::LOCAL_PATH_REGEX); if (! isset($match['local_path'])) { throw new ShouldNotHappenException(); diff --git a/src/FileSystem/PathResolver.php b/src/FileSystem/PathResolver.php index 4a202f19..46fa5e20 100644 --- a/src/FileSystem/PathResolver.php +++ b/src/FileSystem/PathResolver.php @@ -18,7 +18,7 @@ final class PathResolver public static function resolveVendorDirectory(string $filePath): string { - $match = Strings::match($filePath, self::VENDOR_PACKAGE_DIRECTORY_REGEX); + $match = Strings::match(str_replace('\\', '/', $filePath), self::VENDOR_PACKAGE_DIRECTORY_REGEX); if (! isset($match['vendor_package_directory'])) { throw new ShouldNotHappenException('Could not resolve vendor package directory'); }