mirror of https://github.com/django/django.git
Fixed #34496 -- Fixed handling source maps with data URI in ManifestStaticFilesStorage.
Regression in 781b44240a
.
This commit is contained in:
parent
498195bda4
commit
fb535e0a90
|
@ -86,7 +86,7 @@ class HashedFilesMixin:
|
|||
),
|
||||
(
|
||||
(
|
||||
r"(?m)(?P<matched>)^(/\*#[ \t]"
|
||||
r"(?m)^(?P<matched>/\*#[ \t]"
|
||||
r"(?-i:sourceMappingURL)=(?P<url>.*)[ \t]*\*/)$"
|
||||
),
|
||||
"/*# sourceMappingURL=%(url)s */",
|
||||
|
@ -97,7 +97,7 @@ class HashedFilesMixin:
|
|||
"*.js",
|
||||
(
|
||||
(
|
||||
r"(?m)(?P<matched>)^(//# (?-i:sourceMappingURL)=(?P<url>.*))$",
|
||||
r"(?m)^(?P<matched>//# (?-i:sourceMappingURL)=(?P<url>.*))$",
|
||||
"//# sourceMappingURL=%(url)s",
|
||||
),
|
||||
),
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
* {outline: 1px solid red;}
|
||||
/*# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIl9zcmMv*/
|
|
@ -0,0 +1,2 @@
|
|||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIl9zcmMv
|
||||
let a_variable = 1;
|
|
@ -269,6 +269,18 @@ class TestHashedFiles:
|
|||
)
|
||||
self.assertPostCondition()
|
||||
|
||||
def test_css_source_map_data_uri(self):
|
||||
relpath = self.hashed_file_path("cached/source_map_data_uri.css")
|
||||
self.assertEqual(relpath, "cached/source_map_data_uri.3166be10260d.css")
|
||||
with storage.staticfiles_storage.open(relpath) as relfile:
|
||||
content = relfile.read()
|
||||
source_map_data_uri = (
|
||||
b"/*# sourceMappingURL=data:application/json;charset=utf8;base64,"
|
||||
b"eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIl9zcmMv*/"
|
||||
)
|
||||
self.assertIn(source_map_data_uri, content)
|
||||
self.assertPostCondition()
|
||||
|
||||
def test_js_source_map(self):
|
||||
relpath = self.hashed_file_path("cached/source_map.js")
|
||||
self.assertEqual(relpath, "cached/source_map.cd45b8534a87.js")
|
||||
|
@ -307,6 +319,18 @@ class TestHashedFiles:
|
|||
)
|
||||
self.assertPostCondition()
|
||||
|
||||
def test_js_source_map_data_uri(self):
|
||||
relpath = self.hashed_file_path("cached/source_map_data_uri.js")
|
||||
self.assertEqual(relpath, "cached/source_map_data_uri.a68d23cbf6dd.js")
|
||||
with storage.staticfiles_storage.open(relpath) as relfile:
|
||||
content = relfile.read()
|
||||
source_map_data_uri = (
|
||||
b"//# sourceMappingURL=data:application/json;charset=utf8;base64,"
|
||||
b"eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIl9zcmMv"
|
||||
)
|
||||
self.assertIn(source_map_data_uri, content)
|
||||
self.assertPostCondition()
|
||||
|
||||
@override_settings(
|
||||
STATICFILES_DIRS=[os.path.join(TEST_ROOT, "project", "faulty")],
|
||||
STATICFILES_FINDERS=["django.contrib.staticfiles.finders.FileSystemFinder"],
|
||||
|
|
Loading…
Reference in New Issue