Added separated handling of root paths
This commit is contained in:
parent
d949fcc8d6
commit
7bb394e2c4
@ -330,8 +330,13 @@ class Filesystem
|
|||||||
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
|
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
|
||||||
$depth = count($startPathArr) - $index;
|
$depth = count($startPathArr) - $index;
|
||||||
|
|
||||||
// Repeated "../" for each level need to reach the common path
|
// When we need to traverse from the start, and we are starting from a root path, don't add '../'
|
||||||
$traverser = str_repeat('../', $depth);
|
if ($startPath[0] == '/' && $index == 0 && $depth == 1) {
|
||||||
|
$traverser = '';
|
||||||
|
} else {
|
||||||
|
// Repeated "../" for each level need to reach the common path
|
||||||
|
$traverser = str_repeat('../', $depth);
|
||||||
|
}
|
||||||
|
|
||||||
$endPathRemainder = implode('/', array_slice($endPathArr, $index));
|
$endPathRemainder = implode('/', array_slice($endPathArr, $index));
|
||||||
|
|
||||||
|
@ -781,6 +781,8 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('/a/aab/bb', '/a/aa/', '../aab/bb/'),
|
array('/a/aab/bb', '/a/aa/', '../aab/bb/'),
|
||||||
array('/a/aab/bb/', '/a/aa', '../aab/bb/'),
|
array('/a/aab/bb/', '/a/aa', '../aab/bb/'),
|
||||||
array('/a/aab/bb/', '/a/aa/', '../aab/bb/'),
|
array('/a/aab/bb/', '/a/aa/', '../aab/bb/'),
|
||||||
|
array('/a/aab/bb/', '/', 'a/aab/bb/'),
|
||||||
|
array('/a/aab/bb/', '/b/aab', '../../a/aab/bb/'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
|
Reference in New Issue
Block a user