Only redirect GET/HEAD if system.pages.redirect_trailing_slash is true and request has a trailing slash

This commit is contained in:
Matias Griese
2021-02-09 21:23:23 +02:00
parent bd97e817c2
commit 5a9477a402
2 changed files with 6 additions and 0 deletions

View File

@@ -22,6 +22,7 @@
* Fixed renaming flex objects key when using file storage
* Fixed wrong values in Admin pages list [#3214](https://github.com/getgrav/grav/issues/3214)
* Fixed pipelined asset using different hash when extra asset is added to before/after position [#2781](https://github.com/getgrav/grav/issues/2781)
* Only redirect GET/HEAD if `system.pages.redirect_trailing_slash` is true and request has a trailing slash
# v1.7.5
## 02/01/2021

View File

@@ -30,6 +30,7 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use function defined;
use function in_array;
/**
* Class InitializeProcessor
@@ -414,6 +415,10 @@ class InitializeProcessor extends ProcessorBase
protected function handleRedirectRequest(RequestInterface $request): ?ResponseInterface
{
if (!in_array($request->getMethod(), ['GET', 'HEAD'])) {
return null;
}
// Redirect pages with trailing slash if configured to do so.
$uri = $request->getUri();
$path = $uri->getPath() ?: '/';