mirror of
https://github.com/getgrav/grav.git
synced 2026-07-04 11:19:12 +02:00
Fixed issue with redirect_trailing_slash losing query string #2269
This commit is contained in:
@@ -53,8 +53,12 @@ class InitializeProcessor extends ProcessorBase
|
||||
|
||||
// Redirect pages with trailing slash if configured to do so.
|
||||
$path = $uri->path() ?: '/';
|
||||
if ($path !== '/' && $config->get('system.pages.redirect_trailing_slash', false) && Utils::endsWith($path, '/')) {
|
||||
$this->container->redirectLangSafe(rtrim($path, '/'));
|
||||
if ($path !== '/'
|
||||
&& $config->get('system.pages.redirect_trailing_slash', false)
|
||||
&& Utils::endsWith($path, '/')) {
|
||||
|
||||
$redirect = (string) $uri->getCurrentRoute()->withRoot('');
|
||||
$this->container->redirectLangSafe($redirect);
|
||||
}
|
||||
|
||||
$this->container->setLocale();
|
||||
|
||||
@@ -184,6 +184,30 @@ class Route
|
||||
return $this->queryParams[$param] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow the ability to set the route to something else
|
||||
*
|
||||
* @param $route
|
||||
* @return $this
|
||||
*/
|
||||
public function withRoute($route)
|
||||
{
|
||||
$this->route = $route;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow the ability to set the root to something else
|
||||
*
|
||||
* @param $root
|
||||
* @return $this
|
||||
*/
|
||||
public function withRoot($root)
|
||||
{
|
||||
$this->root = $root;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return Route
|
||||
|
||||
Reference in New Issue
Block a user