diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py index 5fa088a29a..07999e00cb 100644 --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -54,7 +54,7 @@ class HashedFilesMixin: )), ('*.js', ( ( - r'(?P)^(//# (?-i:sourceMappingURL)=(?P.*))$', + r'(?m)(?P)^(//# (?-i:sourceMappingURL)=(?P.*))$', '//# sourceMappingURL=%(url)s', ), ( diff --git a/tests/staticfiles_tests/project/documents/cached/source_map.js b/tests/staticfiles_tests/project/documents/cached/source_map.js index b37c5e5701..9d417868a0 100644 --- a/tests/staticfiles_tests/project/documents/cached/source_map.js +++ b/tests/staticfiles_tests/project/documents/cached/source_map.js @@ -1 +1,2 @@ //# sourceMappingURL=source_map.js.map +let a_variable = 1; diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py index 0a34f64394..93335480be 100644 --- a/tests/staticfiles_tests/test_storage.py +++ b/tests/staticfiles_tests/test_storage.py @@ -260,7 +260,7 @@ class TestHashedFiles: 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.cd45b8534a87.js') with storage.staticfiles_storage.open(relpath) as relfile: content = relfile.read() self.assertNotIn(b'//# sourceMappingURL=source_map.js.map', content)