X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/5d2aad6a9e0675dc10c187c8c6c90294f47f22f7..refs/pull/5676/head:/app/Http/Request.php diff --git a/app/Http/Request.php b/app/Http/Request.php index 13892603d..c2d430279 100644 --- a/app/Http/Request.php +++ b/app/Http/Request.php @@ -9,10 +9,8 @@ class Request extends LaravelRequest /** * Override the default request methods to get the scheme and host * to directly use the custom APP_URL, if set. - * - * @return string */ - public function getSchemeAndHttpHost() + public function getSchemeAndHttpHost(): string { $appUrl = config('app.url', null); @@ -27,15 +25,15 @@ class Request extends LaravelRequest * Override the default request methods to get the base URL * to directly use the custom APP_URL, if set. * The base URL never ends with a / but should start with one if not empty. - * - * @return string */ - public function getBaseUrl() + public function getBaseUrl(): string { $appUrl = config('app.url', null); if ($appUrl) { - return '/' . rtrim(implode('/', array_slice(explode('/', $appUrl), 3)), '/'); + $parsedBaseUrl = rtrim(implode('/', array_slice(explode('/', $appUrl), 3)), '/'); + + return empty($parsedBaseUrl) ? '' : ('/' . $parsedBaseUrl); } return parent::getBaseUrl();