Fixed issue with redirect_trailing_slash losing query string #2269

This commit is contained in:
Andy Miller
2019-01-16 17:05:42 -07:00
parent e976aa0f5f
commit 9ca411aa24
2 changed files with 30 additions and 2 deletions

View File

@@ -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();

View File

@@ -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