1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 15:37:51 +02:00

Normalize Base URL during installation

- Fix base url when is appended with a script filename
- Add default base url http://flarum.local when CLI wizard used
- Remove some code duplication
- Add minor improvement to the UX when CLI wizard used
- Add tests
- Extract base url normalisation into its own value object
This commit is contained in:
Stefan Totev
2019-09-23 23:26:51 +01:00
committed by Franz Liedke
parent 09609a9f20
commit 738ca405fe
7 changed files with 168 additions and 19 deletions

View File

@@ -13,6 +13,7 @@ namespace Flarum\Install\Controller;
use Flarum\Http\SessionAuthenticator;
use Flarum\Install\AdminUser;
use Flarum\Install\BaseUrl;
use Flarum\Install\DatabaseConfig;
use Flarum\Install\Installation;
use Flarum\Install\StepFailed;
@@ -54,16 +55,16 @@ class InstallController implements RequestHandlerInterface
public function handle(Request $request): ResponseInterface
{
$input = $request->getParsedBody();
$baseUrl = rtrim((string) $request->getUri(), '/');
$baseUrl = $request->getUri();
try {
$pipeline = $this->installation
->baseUrl($baseUrl)
->baseUrl(BaseUrl::fromUri($baseUrl))
->databaseConfig($this->makeDatabaseConfig($input))
->adminUser($this->makeAdminUser($input))
->settings([
'forum_title' => Arr::get($input, 'forumTitle'),
'mail_from' => 'noreply@'.preg_replace('/^www\./i', '', parse_url($baseUrl, PHP_URL_HOST)),
'mail_from' => 'noreply@'.preg_replace('/^www\./i', '', $baseUrl->getHost()),
'welcome_title' => 'Welcome to '.Arr::get($input, 'forumTitle'),
])
->build();