From 21e9519ab8ecdeaa2f65a34ba81603b05226bbf7 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Fri, 17 Jul 2020 16:05:45 -0500 Subject: [PATCH] Issue #3401 - Unbreak bust_cache --- tests/unit/test_template.py | 2 +- webcompat/templates/__init__.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_template.py b/tests/unit/test_template.py index f773f839a..e3673477c 100644 --- a/tests/unit/test_template.py +++ b/tests/unit/test_template.py @@ -139,7 +139,7 @@ def test_bust_cache_localhost(): def test_bust_cache_production_missing_file(): """Test for cache_bust the path is missing.""" - expected = '/punkcat/nowhere?missing_file' + expected = 'punkcat/nowhere?missing_file' webcompat.app.config['LOCALHOST'] = None assert bust_cache('/punkcat/nowhere') == expected diff --git a/webcompat/templates/__init__.py b/webcompat/templates/__init__.py index c5af2f58a..d81b39979 100644 --- a/webcompat/templates/__init__.py +++ b/webcompat/templates/__init__.py @@ -30,6 +30,8 @@ def bust_cache(file_path): """ if app.config['LOCALHOST']: return file_path + if file_path.startswith('/'): + file_path = file_path[1:] absolute_path = os.path.join(STATIC_PATH, file_path) return file_path + '?' + get_checksum(absolute_path) @@ -41,6 +43,7 @@ def get_checksum(file_path): except KeyError: checksum = md5_checksum(file_path) cache_dict[str(file_path)] = checksum + print('GET_CHECKSUM (after cache miss)', cache_dict) return checksum