if ($isFullUrl && !$forceAppDomain) {
return $path;
}
+
$path = trim($path, '/');
+ $trimBase = rtrim(config('app.url'), '/');
// Remove non-specified domain if forced and we have a domain
if ($isFullUrl && $forceAppDomain) {
+ if (strpos($path, $trimBase) === 0) {
+ $path = trim(substr($path, strlen($trimBase) - 1));
+ }
$explodedPath = explode('/', $path);
$path = implode('/', array_splice($explodedPath, 3));
}
return url($path);
}
- return rtrim(config('app.url'), '/') . '/' . $path;
+ return $trimBase . '/' . $path;
}
/**
<env name="GOOGLE_AUTO_REGISTER" value=""/>
<env name="GOOGLE_AUTO_CONFIRM_EMAIL" value=""/>
<env name="APP_URL" value="http://bookstack.dev"/>
+ <env name="DEBUGBAR_ENABLED" value="false"/>
</php>
</phpunit>
--- /dev/null
+<?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);
+ }
+}
\ No newline at end of file