mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Fixed double path slash URL issue in some cases
- Occurred on system request path usage (Primarily on guest login redirection) when a custom path was not in use. - Added test to cover. For #3404
This commit is contained in:
parent
16222de5fa
commit
ebc69a8f2c
@ -35,7 +35,8 @@ class Request extends LaravelRequest
|
||||
$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();
|
||||
|
@ -34,4 +34,19 @@ class UrlTest extends TestCase
|
||||
$this->assertEquals('/cool/docs', $bsRequest->getBaseUrl());
|
||||
$this->assertEquals('https://donkey.example.com:8091/cool/docs/login', $bsRequest->getUri());
|
||||
}
|
||||
|
||||
public function test_app_url_without_path_does_not_duplicate_path_slash()
|
||||
{
|
||||
config()->set('app.url', 'https://donkey.example.com');
|
||||
|
||||
// Have to manually get and wrap request in our custom type due to testing mechanics
|
||||
$this->get('/settings');
|
||||
$bsRequest = Request::createFrom(request());
|
||||
|
||||
$this->assertEquals('https://donkey.example.com', $bsRequest->getSchemeAndHttpHost());
|
||||
$this->assertEquals('', $bsRequest->getBaseUrl());
|
||||
$this->assertEquals('/settings', $bsRequest->getPathInfo());
|
||||
$this->assertEquals('https://donkey.example.com/settings', $bsRequest->getUri());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user