diff --git a/src/Routing/Routable.php b/src/Routing/Routable.php index e31f3430cc8..69978f284e1 100644 --- a/src/Routing/Routable.php +++ b/src/Routing/Routable.php @@ -30,18 +30,18 @@ public function uri() return app(UrlBuilder::class)->content($this)->build($route); } - public function url() + public function url($follow_redirect = true) { - if ($this->isRedirect()) { + if ($this->isRedirect() && $follow_redirect) { return $this->redirectUrl(); } - return URL::makeRelative($this->absoluteUrl()); + return URL::makeRelative($this->absoluteUrl($follow_redirect)); } - public function absoluteUrl() + public function absoluteUrl($follow_redirect = true) { - if ($this->isRedirect()) { + if ($this->isRedirect() && $follow_redirect) { return $this->redirectUrl(); } diff --git a/src/Structures/Page.php b/src/Structures/Page.php index d922803ee55..3b3df0eccce 100644 --- a/src/Structures/Page.php +++ b/src/Structures/Page.php @@ -36,18 +36,18 @@ public function setUrl($url) return $this; } - public function url() + public function url($follow_redirect = true) { if ($this->url) { return $this->url; } - if ($this->isRedirect()) { + if ($this->isRedirect() && $follow_redirect) { return $this->redirectUrl(); } if ($this->reference && $this->referenceExists()) { - return URL::makeRelative($this->absoluteUrl()); + return URL::makeRelative($this->absoluteUrl($follow_redirect)); } } @@ -178,13 +178,13 @@ public function uri() ->build($this->route); } - public function absoluteUrl() + public function absoluteUrl($follow_redirect = true) { if ($this->url) { return $this->url; } - if ($this->isRedirect()) { + if ($this->isRedirect() && $follow_redirect) { return $this->redirectUrl(); } diff --git a/src/Tags/Structure.php b/src/Tags/Structure.php index c3b4ab01b5e..e292847ccd2 100644 --- a/src/Tags/Structure.php +++ b/src/Tags/Structure.php @@ -63,7 +63,7 @@ public function toArray($tree, $parent = null, $depth = 1) 'parent' => $parent, 'depth' => $depth, 'is_current' => rtrim(URL::getCurrent(), '/') == rtrim($page->url(), '/'), - 'is_parent' => Site::current()->url() === $page->url() ? false : URL::isAncestorOf(URL::getCurrent(), $page->url()), + 'is_parent' => Site::current()->url() === $page->url() ? false : URL::isAncestorOf(URL::getCurrent(), $page->url(false)), 'is_external' => URL::isExternal($page->absoluteUrl()), ]); })->filter()->values()->all();