Skip to content

Commit

Permalink
Expose source maps bug in ManifestStaticFilesStorage
Browse files Browse the repository at this point in the history
Current implementation of `HashedFilesMixin` relies on regex multiline
mode to parse out the sourceMappingURL comment. As is, the filename is
only correctly replaced when the comment is the first and only line in
the JS file (exception to final single new line at EOF).

Updated test case to include additional blank line above and below
sourceMappingURL comment and adjusted the filename hash accordingly.
  • Loading branch information
josephabrahams committed Oct 28, 2021
1 parent afeafd6 commit 3248a4c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
@@ -1 +1,3 @@

//# sourceMappingURL=source_map.js.map

2 changes: 1 addition & 1 deletion tests/staticfiles_tests/test_storage.py
Expand Up @@ -260,7 +260,7 @@ def test_css_import_case_insensitive(self):

def test_js_source_map(self):
relpath = self.hashed_file_path('cached/source_map.js')
self.assertEqual(relpath, 'cached/source_map.9371cbb02a26.js')
self.assertEqual(relpath, 'cached/source_map.956ee8dd2a15.js')
with storage.staticfiles_storage.open(relpath) as relfile:
content = relfile.read()
self.assertNotIn(b'//# sourceMappingURL=source_map.js.map', content)
Expand Down

0 comments on commit 3248a4c

Please sign in to comment.