Fixed #33237 -- Fixed detecting source maps in ManifestStaticFilesStorage for multiline files.

Switched regex to multiline mode in order to match per-line, rather
than against the whole file.

Thanks to Joseph Abrahams for the report.

Regression in 781b44240a.
This commit is contained in:
Carlton Gibson 2021-11-04 10:20:04 +01:00 committed by Mariusz Felisiak
parent fc565cb539
commit 4816dc9428
3 changed files with 3 additions and 2 deletions

View File

@ -54,7 +54,7 @@ class HashedFilesMixin:
)),
('*.js', (
(
r'(?P<matched>)^(//# (?-i:sourceMappingURL)=(?P<url>.*))$',
r'(?m)(?P<matched>)^(//# (?-i:sourceMappingURL)=(?P<url>.*))$',
'//# sourceMappingURL=%(url)s',
),
(

View File

@ -1 +1,2 @@
//# sourceMappingURL=source_map.js.map
let a_variable = 1;

View File

@ -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)