1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2024-10-30 07:32:39 +01:00
BookStack/app/Http/Request.php

42 lines
1.0 KiB
PHP
Raw Normal View History

2021-06-26 17:23:15 +02:00
<?php
namespace BookStack\Http;
use Illuminate\Http\Request as LaravelRequest;
class Request extends LaravelRequest
{
/**
* Override the default request methods to get the scheme and host
* to directly use the custom APP_URL, if set.
*/
2023-02-06 21:00:44 +01:00
public function getSchemeAndHttpHost(): string
{
$appUrl = config('app.url', null);
if ($appUrl) {
return implode('/', array_slice(explode('/', $appUrl), 0, 3));
}
return parent::getSchemeAndHttpHost();
}
/**
* Override the default request methods to get the base URL
* to directly use the custom APP_URL, if set.
2022-04-13 13:46:19 +02:00
* The base URL never ends with a / but should start with one if not empty.
*/
2023-02-06 21:00:44 +01:00
public function getBaseUrl(): string
{
$appUrl = config('app.url', null);
if ($appUrl) {
$parsedBaseUrl = rtrim(implode('/', array_slice(explode('/', $appUrl), 3)), '/');
2022-05-04 22:19:46 +02:00
return empty($parsedBaseUrl) ? '' : ('/' . $parsedBaseUrl);
}
return parent::getBaseUrl();
}
}