From f16fccb275a0579e0c34bdb8f3c841b2fd3174a5 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 9 Sep 2016 18:22:23 +0200 Subject: [PATCH] Fix trim bug --- Uri/Http.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Uri/Http.php b/Uri/Http.php index e1dcfb922..f445afe17 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -14,6 +14,7 @@ * @link http://orange-management.com */ namespace phpOMS\Uri; +use phpOMS\Utils\StringUtils; /** * Uri interface. @@ -154,7 +155,11 @@ class Http implements UriInterface $this->user = $url['user'] ?? null; $this->pass = $url['pass'] ?? null; $this->path = $url['path'] ?? null; - $this->path = rtrim($this->path, '.php'); + + if(StringUtils::endsWith($this->path, '.php')) { + $this->path = substr($this->path, 0, -4); + } + $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; $this->queryString = $this->query;