From f1af4ac4d8321bb94499e3cf665db382157489cc Mon Sep 17 00:00:00 2001
From: Dominik Hebeler <dominik@hebeler.club>
Date: Fri, 1 Sep 2023 10:47:01 +0200
Subject: [PATCH] fix wrong url generation

---
 metager/app/Http/Controllers/LangSelector.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/metager/app/Http/Controllers/LangSelector.php b/metager/app/Http/Controllers/LangSelector.php
index 7c80d58e1..42d3f4eae 100644
--- a/metager/app/Http/Controllers/LangSelector.php
+++ b/metager/app/Http/Controllers/LangSelector.php
@@ -27,6 +27,9 @@ class LangSelector extends Controller
             $path = isset($components["path"]) ? $components["path"] : "/";
             $path .= isset($components["query"]) ? "?" . $components["query"] : "";
             $path = preg_replace("/^\/[a-z]{2}-[A-Z]{2}/", "", $path);
+            if (empty($path)) {
+                $path = "/";
+            }
             if (($host === $current_host || in_array($current_host, $allowed_hosts)) && preg_match("/^http(s)?:\/\//", $previous)) { // only if the host of that URL matches the current host
                 $previous_url = LaravelLocalization::getLocalizedUrl(null, $path);
             }
-- 
GitLab