Refactor Uri::resolveRelativeUri()

This commit is contained in:
Giuseppe Criscione 2018-10-19 20:44:48 +02:00
parent 05aee2adf8
commit 9d4f37df68

View File

@ -327,7 +327,7 @@ class Uri
if ($uri[0] !== '/') {
$path = explode('/', trim(static::path($base), '/'));
}
if (count($path) > 0 && $base[strlen($base) - 1] !== '/') {
if (substr($base, -1) !== '/') {
array_pop($path);
}
foreach (explode('/', static::path($uri)) as $segment) {
@ -335,13 +335,11 @@ class Uri
continue;
}
if ($segment === '..') {
if (count($segment) > 0) {
array_pop($path);
}
} else {
array_push($path, $segment);
$path[] = $segment;
}
}
return Uri::make(array('path' => implode('/', $path)), $base);
return static::make(array('path' => implode('/', $path)), $base);
}
}