From a10308a8f6bd0368887a1ee17e2b6bcf524627b5 Mon Sep 17 00:00:00 2001 From: KJ Date: Thu, 16 May 2024 13:20:35 -0400 Subject: [PATCH] Fix route and redirect methods error when path not start with slash. --- src/Libs/Router.php | 2 +- src/Libs/View.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Libs/Router.php b/src/Libs/Router.php index 38c3187..24cdbab 100644 --- a/src/Libs/Router.php +++ b/src/Libs/Router.php @@ -100,7 +100,7 @@ class Router { */ public static function redirect(string $path): void { - header('Location: '.static::basePath().substr($path,1)); + header('Location: '.static::basePath().ltrim($path, '/')); exit; } diff --git a/src/Libs/View.php b/src/Libs/View.php index 9f878ba..a6de24f 100644 --- a/src/Libs/View.php +++ b/src/Libs/View.php @@ -156,7 +156,7 @@ class View extends Neuron { public function route(string $path = '/'): string { if (defined('SITE_URL') && !empty(SITE_URL)) - return SITE_URL.substr($path,1); + return SITE_URL.ltrim($path, '/'); return $path; }