public static function resolvePath($urlPath, $basePath)
{
$urlParts = self::splitPath($urlPath);
$baseParts = self::splitPath($basePath);
$resolved = array_slice($baseParts, 0, -1);
foreach ($urlParts as $part) {
if ($part === '..') {
array_pop($resolved);
} else {
$resolved[] = $part;
}
}
return '/' . implode('/', $resolved);
}
/** * */ public function testResolvePath() { $this->assertEquals('/a/c', Url::resolvePath('c', '/a/b')); $this->assertEquals('/a/d/f', Url::resolvePath('../d/./e/../f', '/a/b/c')); }