From 013746c10a44ef1bf4daeffce5bb0a27ff4a0a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Jeleni=C4=87?= Date: Thu, 23 Nov 2023 16:56:26 +0100 Subject: [PATCH] Fixes environ paths when default_locale set (#873) If the default_locale was set and the URL path didn't contain a language code, it was behaving as if there was a language code in the URL. In that case, it was moving part of the PATH_INFO to SCRIPT_NAME, but as there wasn't any language code in the URL, it moved something else. This fixes that. --- pywb/apps/frontendapp.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pywb/apps/frontendapp.py b/pywb/apps/frontendapp.py index a10c7a42..9ebb036f 100644 --- a/pywb/apps/frontendapp.py +++ b/pywb/apps/frontendapp.py @@ -667,10 +667,14 @@ class FrontEndApp(object): # store original script_name (original prefix) before modifications are made environ['ORIG_SCRIPT_NAME'] = environ.get('SCRIPT_NAME') - lang = args.pop('lang', self.default_locale) + lang = args.pop('lang', '') if lang: pop_path_info(environ) + + if lang: environ['pywb_lang'] = lang + elif self.default_locale: + environ['pywb_lang'] = self.default_locale response = endpoint(environ, **args)