Skip to content

Commit

Permalink
Fix the front end preview (see contao#1972)
Browse files Browse the repository at this point in the history
Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes contao#1968
| Docs PR or issue | -

Commits
-------

8f44044 Fix the front end preview
0c321e4 Use Request::getBaseUrl()
9e3c402 Reset the tests
3148aee Adjust the test
  • Loading branch information
leofeyer authored and Alexej Kossmann committed Apr 6, 2021
1 parent 274e2a9 commit fc4e562
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core-bundle/src/Controller/BackendPreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ public function __invoke(Request $request): Response
return new RedirectResponse($targetUrl);
}

return new RedirectResponse('/');
return new RedirectResponse($request->getBaseUrl().'/');
}
}
11 changes: 9 additions & 2 deletions core-bundle/tests/Controller/BackendPreviewControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,18 @@ public function testRedirectsToRootPage(): void
$this->mockAuthorizationChecker()
);

$request = $this->mockRequest();
$request
->expects($this->once())
->method('getBaseUrl')
->willReturn('/preview.php')
;

/** @var RedirectResponse $response */
$response = $controller($this->mockRequest());
$response = $controller($request);

$this->assertInstanceOf(RedirectResponse::class, $response);
$this->assertSame('/', $response->getTargetUrl());
$this->assertSame('/preview.php/', $response->getTargetUrl());
}

/**
Expand Down

0 comments on commit fc4e562

Please sign in to comment.