mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 11:05:56 +02:00
Merge pull request #98 from webbuilders-group/remove-extension-fix
BUGFIX: Fixed redirecting to strip extensions incorrectly redirecting
This commit is contained in:
commit
aca243bfe3
@ -166,7 +166,7 @@ class DocumentationViewer extends Controller
|
||||
if (DocumentationHelper::get_extension($url)) {
|
||||
$this->response = new SS_HTTPResponse();
|
||||
$this->response->redirect(
|
||||
DocumentationHelper::trim_extension_off($url) .'/',
|
||||
Director::absoluteURL(DocumentationHelper::trim_extension_off($url)) .'/',
|
||||
301
|
||||
);
|
||||
|
||||
|
@ -217,4 +217,17 @@ class DocumentationViewerTest extends FunctionalTest
|
||||
$response = $this->get('dev/docs/all/');
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
}
|
||||
|
||||
|
||||
public function testRedirectStripExtension()
|
||||
{
|
||||
// get url with .md extension
|
||||
$response = $this->get('dev/docs/en/doc_test/3.0/tutorials.md');
|
||||
|
||||
// response should be a 301 redirect
|
||||
$this->assertEquals(301, $response->getStatusCode());
|
||||
|
||||
// redirect should have been to the absolute url minus the .md extension
|
||||
$this->assertEquals(Director::absoluteURL('dev/docs/en/doc_test/3.0/tutorials/'), $response->getHeader('Location'));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user