From 9d4f37df680a4216af74c12378f1e7ed01f997ce Mon Sep 17 00:00:00 2001 From: Giuseppe Criscione Date: Fri, 19 Oct 2018 20:44:48 +0200 Subject: [PATCH] Refactor `Uri::resolveRelativeUri()` --- formwork/Utils/Uri.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/formwork/Utils/Uri.php b/formwork/Utils/Uri.php index 7ed1d168..558b9c74 100755 --- a/formwork/Utils/Uri.php +++ b/formwork/Utils/Uri.php @@ -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); - } + 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); } }