[Filesystem] Fixed relative path calculation for end path which is a subdirectory of the start path.
This commit is contained in:
parent
bc93787a0d
commit
22e2ad80c9
@ -186,7 +186,7 @@ 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)
|
||||||
$diffPath = trim(substr($startPath, $offset), DIRECTORY_SEPARATOR);
|
$diffPath = trim(substr($startPath, $offset), DIRECTORY_SEPARATOR);
|
||||||
$depth = substr_count($diffPath, DIRECTORY_SEPARATOR) + 1;
|
$depth = strlen($diffPath) > 0 ? substr_count($diffPath, DIRECTORY_SEPARATOR) + 1 : 0;
|
||||||
|
|
||||||
// Repeated "../" for each level need to reach the common path
|
// Repeated "../" for each level need to reach the common path
|
||||||
$traverser = str_repeat('../', $depth);
|
$traverser = str_repeat('../', $depth);
|
||||||
|
@ -448,7 +448,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('/var/lib/symfony/src/Symfony', '/var/lib/symfony/src/Symfony/Component/', '../'),
|
array('/var/lib/symfony/src/Symfony', '/var/lib/symfony/src/Symfony/Component/', '../'),
|
||||||
array('var/lib/symfony/', 'var/lib/symfony/src/Symfony/Component', '../../../'),
|
array('var/lib/symfony/', 'var/lib/symfony/src/Symfony/Component', '../../../'),
|
||||||
array('/usr/lib/symfony/', '/var/lib/symfony/src/Symfony/Component', '../../../../../../usr/lib/symfony/'),
|
array('/usr/lib/symfony/', '/var/lib/symfony/src/Symfony/Component', '../../../../../../usr/lib/symfony/'),
|
||||||
array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/', '../src/Symfony/'),
|
array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/', 'src/Symfony/'),
|
||||||
);
|
);
|
||||||
|
|
||||||
// fix directory separator
|
// fix directory separator
|
||||||
|
Reference in New Issue
Block a user