Skip to content

Commit

Permalink
normalize drive letter case
Browse files Browse the repository at this point in the history
  • Loading branch information
crishoj committed Apr 26, 2020
1 parent e75b87b commit d5d8d00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Symfony/Component/Filesystem/Filesystem.php
Expand Up @@ -455,9 +455,9 @@ public function makePathRelative($endPath, $startPath)
$startPath = str_replace('\\', '/', $startPath);
}

$stripDriveLetter = function ($path) {
$splitDriveLetter = function ($path) {
return (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0]))
? [substr($path, 2), $path[0]]
? [substr($path, 2), strtoupper($path[0])]
: [$path, null];
};

Expand All @@ -475,8 +475,8 @@ public function makePathRelative($endPath, $startPath)
return $result;
};

list($endPath, $endDriveLetter) = $stripDriveLetter($endPath);
list($startPath, $startDriveLetter) = $stripDriveLetter($startPath);
list($endPath, $endDriveLetter) = $splitDriveLetter($endPath);
list($startPath, $startDriveLetter) = $splitDriveLetter($startPath);

$startPathArr = $splitPath($startPath, static::isAbsolutePath($startPath));
$endPathArr = $splitPath($endPath, static::isAbsolutePath($endPath));
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Expand Up @@ -1111,6 +1111,7 @@ public function providePathsForMakePathRelative()
['/../aa/bb/cc', '/aa/dd/..', 'bb/cc/'],
['/../../aa/../bb/cc', '/aa/dd/..', '../bb/cc/'],
['C:/aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'],
['C:/aa/bb/cc', 'c:/aa/dd/..', 'bb/cc/'],
['c:/aa/../bb/cc', 'c:/aa/dd/..', '../bb/cc/'],
['C:/aa/bb/../../cc', 'C:/aa/../dd/..', 'cc/'],
['C:/../aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'],
Expand Down

0 comments on commit d5d8d00

Please sign in to comment.