0
0
mirror of https://github.com/django/django.git synced 2024-11-28 21:43:13 +01:00

Refs #33446 -- Allowed variable whitespace in CSS source map references.

Follow up to dc8bb35e39.

The Webpack default is to output CSS source map comments like
`/*# sourceMappingURL=main.css.map*/`. Also, Chromium allows tabs.
This commit is contained in:
Adam Johnson 2022-03-03 17:28:57 +00:00 committed by Mariusz Felisiak
parent 24cc51f8fb
commit b811364421
4 changed files with 20 additions and 3 deletions

View File

@ -57,7 +57,10 @@ class HashedFilesMixin:
"""@import url("%(url)s")""",
),
(
r"(?m)(?P<matched>)^(/\*# (?-i:sourceMappingURL)=(?P<url>.*) \*/)$",
(
r"(?m)(?P<matched>)^(/\*#[ \t]"
r"(?-i:sourceMappingURL)=(?P<url>.*)[ \t]*\*/)$"
),
"/*# sourceMappingURL=%(url)s */",
),
),

View File

@ -1,2 +1,2 @@
* {outline: 1px solid red;}
/*# sourceMappingURL=source_map.css.map */
/*# sourceMappingURL=source_map.css.map*/

View File

@ -0,0 +1,2 @@
* {outline: 1px solid red;}
/*# sourceMappingURL=source_map.css.map */

View File

@ -237,7 +237,19 @@ class TestHashedFiles:
self.assertEqual(relpath, "cached/source_map.b2fceaf426aa.css")
with storage.staticfiles_storage.open(relpath) as relfile:
content = relfile.read()
self.assertNotIn(b"/*# sourceMappingURL=source_map.css.map */", content)
self.assertNotIn(b"/*# sourceMappingURL=source_map.css.map*/", content)
self.assertIn(
b"/*# sourceMappingURL=source_map.css.99914b932bd3.map */",
content,
)
self.assertPostCondition()
def test_css_source_map_tabs(self):
relpath = self.hashed_file_path("cached/source_map_tabs.css")
self.assertEqual(relpath, "cached/source_map_tabs.b2fceaf426aa.css")
with storage.staticfiles_storage.open(relpath) as relfile:
content = relfile.read()
self.assertNotIn(b"/*#\tsourceMappingURL=source_map.css.map\t*/", content)
self.assertIn(
b"/*# sourceMappingURL=source_map.css.99914b932bd3.map */",
content,