mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 04:05:57 +00:00
Merge branch 'v0.24-dev'
This commit is contained in:
commit
ffc1aa873e
@ -92,10 +92,15 @@ function baseUrl($path, $forceAppDomain = false)
|
|||||||
if ($isFullUrl && !$forceAppDomain) {
|
if ($isFullUrl && !$forceAppDomain) {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = trim($path, '/');
|
$path = trim($path, '/');
|
||||||
|
$trimBase = rtrim(config('app.url'), '/');
|
||||||
|
|
||||||
// Remove non-specified domain if forced and we have a domain
|
// Remove non-specified domain if forced and we have a domain
|
||||||
if ($isFullUrl && $forceAppDomain) {
|
if ($isFullUrl && $forceAppDomain) {
|
||||||
|
if (strpos($path, $trimBase) === 0) {
|
||||||
|
$path = trim(substr($path, strlen($trimBase) - 1));
|
||||||
|
}
|
||||||
$explodedPath = explode('/', $path);
|
$explodedPath = explode('/', $path);
|
||||||
$path = implode('/', array_splice($explodedPath, 3));
|
$path = implode('/', array_splice($explodedPath, 3));
|
||||||
}
|
}
|
||||||
@ -105,7 +110,7 @@ function baseUrl($path, $forceAppDomain = false)
|
|||||||
return url($path);
|
return url($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rtrim(config('app.url'), '/') . '/' . $path;
|
return $trimBase . '/' . $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"php": ">=7.0.0",
|
"php": ">=7.0.0",
|
||||||
"ext-tidy": "*",
|
"ext-tidy": "*",
|
||||||
"ext-dom": "*",
|
"ext-dom": "*",
|
||||||
"laravel/framework": "~5.5.42",
|
"laravel/framework": "~5.5.44",
|
||||||
"fideloper/proxy": "~3.3",
|
"fideloper/proxy": "~3.3",
|
||||||
"intervention/image": "^2.4",
|
"intervention/image": "^2.4",
|
||||||
"laravel/socialite": "^3.0",
|
"laravel/socialite": "^3.0",
|
||||||
|
811
composer.lock
generated
811
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -42,5 +42,6 @@
|
|||||||
<env name="GOOGLE_AUTO_REGISTER" value=""/>
|
<env name="GOOGLE_AUTO_REGISTER" value=""/>
|
||||||
<env name="GOOGLE_AUTO_CONFIRM_EMAIL" value=""/>
|
<env name="GOOGLE_AUTO_CONFIRM_EMAIL" value=""/>
|
||||||
<env name="APP_URL" value="http://bookstack.dev"/>
|
<env name="APP_URL" value="http://bookstack.dev"/>
|
||||||
|
<env name="DEBUGBAR_ENABLED" value="false"/>
|
||||||
</php>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
19
tests/HelpersTest.php
Normal file
19
tests/HelpersTest.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php namespace Tests;
|
||||||
|
|
||||||
|
class HelpersTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function test_base_url_takes_config_into_account()
|
||||||
|
{
|
||||||
|
config()->set('app.url', 'http://example.com/bookstack');
|
||||||
|
$result = baseUrl('/');
|
||||||
|
$this->assertEquals('http://example.com/bookstack/', $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_base_url_takes_extra_path_into_account_on_forced_domain()
|
||||||
|
{
|
||||||
|
config()->set('app.url', 'http://example.com/bookstack');
|
||||||
|
$result = baseUrl('http://example.com/bookstack/', true);
|
||||||
|
$this->assertEquals('http://example.com/bookstack/', $result);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user