From dcbd4e52a6376b8d64d2d1331bdb7507782c01d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Jeleni=C4=87?= Date: Tue, 7 Nov 2023 19:05:10 +0100 Subject: [PATCH] Fixes get_locale_prefixes() wrong paths 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 7f0cbc88..37940e28 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():