From 2c52f544c1bf0ac4db495334ccda4428aa806465 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 26 Mar 2016 16:46:14 +0100 Subject: [PATCH] Fixing ltrim of directory structure --- Uri/Http.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Uri/Http.php b/Uri/Http.php index b38d6c2e7..d8601d5af 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -39,7 +39,7 @@ class Http implements UriInterface * @var string * @since 1.0.0 */ - private $rootPath = ''; + private $rootPath = '/'; /** * Uri. @@ -306,7 +306,7 @@ class Http implements UriInterface $this->pass = $url['pass'] ?? null; $this->path = $url['path'] ?? null; $this->path = rtrim($this->path, '.php'); - $this->path = ltrim($this->path, $this->rootPath); // TODO: this could cause a bug if the rootpath is the same as a regular path which is usually the language + $this->path = strpos($this->path, $this->rootPath) === 0 ? substr($this->path, strlen($this->rootPath), strlen($this->path)) : $this->path; // TODO: this could cause a bug if the rootpath is the same as a regular path which is usually the language $this->query = $url['query'] ?? null; if (isset($this->query)) {