Skip to content

Commit

Permalink
Merge pull request #3402 from /issues/3401/1
Browse files Browse the repository at this point in the history
Fixes #3401 - Unbreak bust_cache
  • Loading branch information
Karl Dubost authored Jul 20, 2020
2 parents e6890e3 + 21e9519 commit ddafbff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
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

0 comments on commit ddafbff

Please sign in to comment.