Allow configure SITE_URL with or without slash at end.

This commit is contained in:
KJ 2024-05-16 13:48:49 -04:00
parent a10308a8f6
commit b85fb7e034
2 changed files with 2 additions and 2 deletions

View File

@ -83,7 +83,7 @@ class Router {
public static function basePath(): string public static function basePath(): string
{ {
if (defined('SITE_URL') && !empty(SITE_URL)) 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); return str_replace($_SERVER['DOCUMENT_ROOT'], '/', ROOT_DIR);
} }

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.ltrim($path, '/'); return rtrim(SITE_URL, '/').'/'.ltrim($path, '/');
return $path; return $path;
} }