Upgrade to 4.4.1

This commit is contained in:
Bastian Allgeier
2024-09-23 11:46:43 +02:00
parent 8bc7250b68
commit 49287c7a5e
8 changed files with 30 additions and 42 deletions

View File

@@ -3,7 +3,6 @@
namespace Kirby\Cms;
use Kirby\Filesystem\F;
use Kirby\Toolkit\Str;
class LanguageRoutes
{
@@ -30,26 +29,9 @@ class LanguageRoutes
'pattern' => $language->pattern(),
'method' => 'ALL',
'env' => 'site',
'action' => function ($path = null) use ($kirby, $language) {
'action' => function ($path = null) use ($language) {
$result = $language->router()->call($path);
// redirect secondary-language pages that have
// been accessed with non-translated slugs in their path
// to their fully translated URL
if ($path !== null && $result instanceof Page) {
if (Str::endsWith($result->url(), $path) === false) {
$url = $result->url();
$query = $kirby->request()->query()->toString();
// preserve query across redirect
if (empty($query) === false) {
$url .= '?' . $query;
}
return $kirby->response()->redirect($url);
}
}
// explicitly test for null as $result can
// contain falsy values that should still be returned
if ($result !== null) {