From b85fb7e0347c0dc633c7183ccaf189c7bbeb571e Mon Sep 17 00:00:00 2001 From: KJ Date: Thu, 16 May 2024 13:48:49 -0400 Subject: [PATCH] Allow configure SITE_URL with or without slash at end. --- 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 24cdbab..5f23af9 100644 --- a/src/Libs/Router.php +++ b/src/Libs/Router.php @@ -83,7 +83,7 @@ class Router { public static function basePath(): string { if (defined('SITE_URL') && !empty(SITE_URL)) - return parse_url(SITE_URL, PHP_URL_PATH); + return rtrim(parse_url(SITE_URL, PHP_URL_PATH), '/').'/'; return str_replace($_SERVER['DOCUMENT_ROOT'], '/', ROOT_DIR); } diff --git a/src/Libs/View.php b/src/Libs/View.php index a6de24f..8a1774d 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.ltrim($path, '/'); + return rtrim(SITE_URL, '/').'/'.ltrim($path, '/'); return $path; }