From eb421bc95ed8bfce9f4b8caa3f018673802c391b Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 28 Jun 2015 09:23:48 -0600 Subject: [PATCH] more progress on matching lang keys --- system/src/Grav/Common/Uri.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index 1bfd73f96..34fc4a372 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -87,13 +87,18 @@ class Uri // process params $uri = $this->processParams($uri, $config->get('system.param_sep')); - $regex = '/(\/(?:'.$language->getAvailablekeys().')\/).*/'; + $regex = '/(\/('.$language->getAvailablekeys().'\/)).*/'; - if (preg_match($regex, $uri, $matches)) { - $uri = preg_replace("/\\".$matches[1]."/", '', $matches[0], 1); - $lang = $matches[2]; + // if languages set + if ($language->defaultKey()) { + if (preg_match($regex, $uri, $matches)) { + $lang = $matches[2]; + } else { + $lang = $language->getDefaultKey(); + } } + // split the URL and params $bits = parse_url($uri);