Skip to content

Fixes #3401 - Unbreak bust_cache #3402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/unit/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions webcompat/templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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


Expand Down