From 52c7d8dfb7b7aec701db817c18328760cc2309ce Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 23 Jan 2019 10:55:32 +0200 Subject: [PATCH] Fixed `Grav\Framework\Route::__toString()` returning relative URL, not relative route --- CHANGELOG.md | 1 + system/src/Grav/Framework/Route/Route.php | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 764e6e5d2..e88d6f137 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ * Fixed issue with `redirect_trailing_slash` losing query string [#2269](https://github.com/getgrav/grav/issues/2269) * Fixed failed login if user attempts to log in with upper case non-english letters * Removed extra authenticated/authorized fields when saving existing user from a form + * Fixed `Grav\Framework\Route::__toString()` returning relative URL, not relative route # v1.6.0-beta.7 ## 12/14/2018 diff --git a/system/src/Grav/Framework/Route/Route.php b/system/src/Grav/Framework/Route/Route.php index b79938ea6..0ac8ce64e 100644 --- a/system/src/Grav/Framework/Route/Route.php +++ b/system/src/Grav/Framework/Route/Route.php @@ -259,11 +259,12 @@ class Route } /** + * @param bool $includeRoot * @return string */ - public function __toString() + public function toString(bool $includeRoot = false) { - $url = $this->getUriPath(); + $url = $this->getUriPath($includeRoot); if ($this->queryParams) { $url .= '?' . $this->getUriQuery(); @@ -272,6 +273,14 @@ class Route return $url; } + /** + * @return string + */ + public function __toString() + { + return $this->toString(); + } + /** * @param string $type * @param string $param @@ -297,11 +306,12 @@ class Route } /** + * @param bool $includeRoot * @return string */ - protected function getUriPath() + protected function getUriPath($includeRoot = false) { - $parts = [$this->root]; + $parts = $includeRoot ? [$this->root] : ['']; if ($this->language !== '') { $parts[] = $this->language;