From 57b3295c211b2cb24f4ec4d11220f8b59ded97f1 Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Fri, 6 Jan 2023 06:05:40 +0100 Subject: [PATCH] updated getUrl() to accommodate all url patterns --- src/Config/Auth.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Config/Auth.php b/src/Config/Auth.php index a1ef87edb..32be8ba35 100644 --- a/src/Config/Auth.php +++ b/src/Config/Auth.php @@ -374,8 +374,21 @@ public function registerRedirect(): string protected function getUrl(string $url): string { - return strpos($url, 'http') === 0 - ? $url - : rtrim(site_url($url), '/ '); + // To accommodate all url patterns + $final_url = ""; + switch ($url) { + case strpos($url, 'http') === 0: // URL begins with 'http'. E.g. http://example.com + $final_url = $url; + break; + + case route_to($url) != null: // URL is a named-route + $final_url = route_to($url); + break; + + default: // URL is a route (URI path) + $final_url = rtrim(site_url($url), '/ '); + break; + } + return $final_url; } }