mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Made HashedFilesMixin ignore URLs without a path.
This commit is contained in:
parent
d80a258553
commit
e6f36ea0a9
@ -202,6 +202,10 @@ class HashedFilesMixin:
|
||||
# Strip off the fragment so a path-like fragment won't interfere.
|
||||
url_path, fragment = urldefrag(url)
|
||||
|
||||
# Ignore URLs without a path
|
||||
if not url_path:
|
||||
return matched
|
||||
|
||||
if url_path.startswith("/"):
|
||||
# Otherwise the condition above would have returned prematurely.
|
||||
assert url_path.startswith(settings.STATIC_URL)
|
||||
|
@ -5,5 +5,6 @@ body {
|
||||
background: url("data:foobar");
|
||||
background: url("chrome:foobar");
|
||||
background: url("//foobar");
|
||||
background: url();
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class TestHashedFiles:
|
||||
|
||||
def test_path_ignored_completely(self):
|
||||
relpath = self.hashed_file_path("cached/css/ignored.css")
|
||||
self.assertEqual(relpath, "cached/css/ignored.554da52152af.css")
|
||||
self.assertEqual(relpath, "cached/css/ignored.55e7c226dda1.css")
|
||||
with storage.staticfiles_storage.open(relpath) as relfile:
|
||||
content = relfile.read()
|
||||
self.assertIn(b"#foobar", content)
|
||||
@ -74,6 +74,7 @@ class TestHashedFiles:
|
||||
self.assertIn(b"data:foobar", content)
|
||||
self.assertIn(b"chrome:foobar", content)
|
||||
self.assertIn(b"//foobar", content)
|
||||
self.assertIn(b"url()", content)
|
||||
self.assertPostCondition()
|
||||
|
||||
def test_path_with_querystring(self):
|
||||
|
Loading…
Reference in New Issue
Block a user