From 5a21c4d7f6a235c84a583555028fbcab61fe817f Mon Sep 17 00:00:00 2001 From: Julien Deniau Date: Thu, 6 Feb 2020 10:08:50 +0100 Subject: [PATCH] Fix "lang" selector in url location.search.match(/lang=([a-z]+)/) does return `['lang=fr', 'fr']` if it does match and thus does not found the language with the query parameter. This commit fixes this comportment --- index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index ad3b999..9ea00ff 100644 --- a/index.html +++ b/index.html @@ -286,7 +286,8 @@ } function trans(key) { - const queryLang = location.search.match(/lang=([a-z]+)/); + var matchLang = location.search.match(/lang=([a-z]+)/); + var queryLang = matchLang ? matchLang[1] : null; var locale = queryLang || navigator.language || navigator.userLanguage; var translations = getTranslations();