Skip to content

Commit 1bb996e

Browse files
authored
Merge pull request #35 from madapaja/fix-redirect-html
Fix redirect html
2 parents 6c73406 + bcb7072 commit 1bb996e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/TwigRenderer.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,23 @@ public function render(ResourceObject $ro)
5959

6060
if ($this->isNoContent($ro)) {
6161
$ro->view = '';
62-
} elseif ($this->isRedirect($ro)) {
62+
63+
return $ro->view;
64+
}
65+
if ($this->isRedirect($ro)) {
6366
$ro->view = $this->renderRedirectView($ro);
64-
} else {
65-
$ro->view = $this->renderView($ro);
67+
68+
return $ro->view;
6669
}
70+
$ro->view = $this->renderView($ro);
6771

6872
return $ro->view;
6973
}
7074

7175
private function setContentType(ResourceObject $ro)
7276
{
73-
if (! isset($ro->headers['content-type'])) {
74-
$ro->headers['content-type'] = 'text/html; charset=utf-8';
77+
if (! isset($ro->headers['Content-Type'])) {
78+
$ro->headers['Content-Type'] = 'text/html; charset=utf-8';
7579
}
7680
}
7781

@@ -84,9 +88,11 @@ private function renderView(ResourceObject $ro)
8488

8589
private function renderRedirectView(ResourceObject $ro)
8690
{
87-
$url = $ro->headers['Location'];
88-
89-
return $this->twig->render($this->redirectPage, ['url' => $url]);
91+
try {
92+
return $this->twig->render($this->redirectPage, ['url' => $ro->headers['Location']]);
93+
} catch (LoaderError $e) {
94+
return '';
95+
}
9096
}
9197

9298
/**

0 commit comments

Comments
 (0)