From 79140441dfb722897e8b9a101552c41c724cc0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Jeleni=C4=87?= Date: Thu, 23 Nov 2023 16:50:56 +0100 Subject: [PATCH] Fixes switch_locale not adding locale if missing from URL (#871) If the two letter language code was missing in the URI, switch_locale(locale) didn't add it (it worked fine if it was present). That means that it produced the same URL for all locales, each missing the two letter language code in the URL. --- pywb/rewrite/templateview.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pywb/rewrite/templateview.py b/pywb/rewrite/templateview.py index 7f0cbc88..518df18b 100644 --- a/pywb/rewrite/templateview.py +++ b/pywb/rewrite/templateview.py @@ -178,7 +178,7 @@ class JinjaEnv(object): request_uri = environ.get('REQUEST_URI', environ.get('PATH_INFO')) - if curr_loc: + if curr_loc and request_uri.startswith('/' + curr_loc + '/'): return request_uri.replace(curr_loc, locale, 1) app_prefix = environ.get('pywb.app_prefix', '')