Fix route and redirect methods error when path not start with slash.

This commit is contained in:
KJ 2024-05-16 13:20:35 -04:00
parent 9a1e5a2379
commit a10308a8f6
2 changed files with 2 additions and 2 deletions

View File

@ -100,7 +100,7 @@ class Router {
*/ */
public static function redirect(string $path): void public static function redirect(string $path): void
{ {
header('Location: '.static::basePath().substr($path,1)); header('Location: '.static::basePath().ltrim($path, '/'));
exit; exit;
} }

View File

@ -156,7 +156,7 @@ class View extends Neuron {
public function route(string $path = '/'): string public function route(string $path = '/'): string
{ {
if (defined('SITE_URL') && !empty(SITE_URL)) if (defined('SITE_URL') && !empty(SITE_URL))
return SITE_URL.substr($path,1); return SITE_URL.ltrim($path, '/');
return $path; return $path;
} }