[Filesystem] Fixed relative path calculation for paths with various combinations of trailing directory separators.
This commit is contained in:
parent
dee79e910d
commit
bc93787a0d
@ -185,7 +185,8 @@ class Filesystem
|
||||
}
|
||||
|
||||
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
|
||||
$depth = substr_count(substr($startPath, $offset), DIRECTORY_SEPARATOR) + 1;
|
||||
$diffPath = trim(substr($startPath, $offset), DIRECTORY_SEPARATOR);
|
||||
$depth = substr_count($diffPath, DIRECTORY_SEPARATOR) + 1;
|
||||
|
||||
// Repeated "../" for each level need to reach the common path
|
||||
$traverser = str_repeat('../', $depth);
|
||||
|
@ -443,6 +443,9 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$paths = array(
|
||||
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/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('/usr/lib/symfony/', '/var/lib/symfony/src/Symfony/Component', '../../../../../../usr/lib/symfony/'),
|
||||
array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/', '../src/Symfony/'),
|
||||
|
Reference in New Issue
Block a user