From 7879dd022263200b8b628be8b8539e8114d6082c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Jeleni=C4=87?= Date: Thu, 23 Nov 2023 16:59:06 +0100 Subject: [PATCH] Fixes get_locale_prefixes() wrong paths (#874) If default_locale was set, and a web page was visited that doesn't have a langauge code in the path in the URL, the URL path parts returned by get_locale_prefixes() was wrong (e.g. /hrst/ instead of /hr/test/). --- pywb/rewrite/templateview.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pywb/rewrite/templateview.py b/pywb/rewrite/templateview.py index 518df18b..208c2f4c 100644 --- a/pywb/rewrite/templateview.py +++ b/pywb/rewrite/templateview.py @@ -196,11 +196,11 @@ def get_locale_prefixes(context): orig_prefix = environ.get('pywb.app_prefix', '') coll = environ.get('SCRIPT_NAME', '') - if orig_prefix: + if orig_prefix and coll.startswith(orig_prefix): coll = coll[len(orig_prefix):] curr_loc = environ.get('pywb_lang', '') - if curr_loc: + if curr_loc and coll.startswith('/' + curr_loc): coll = coll[len(curr_loc) + 1:] for locale in loc_map.keys():