Support cache-busting suffix on asset URLs with fragments.

This commit is contained in:
Carl Meyer
2012-09-22 20:51:32 -06:00
parent 8279b90942
commit 11f751dbb0
2 changed files with 25 additions and 0 deletions

View File

@@ -124,6 +124,24 @@ class CssAbsolutizingTestCase(TestCase):
"p { filter: Alpha(src='%(url)simg/python.png?%(hash)s') }") % params
self.assertEqual(output, filter.input(filename=filename, basename='css/url/test.css'))
def test_css_absolute_filter_url_fragment(self):
filename = os.path.join(settings.COMPRESS_ROOT, 'css/url/test.css')
imagefilename = os.path.join(settings.COMPRESS_ROOT, 'img/python.png')
params = {
'url': settings.COMPRESS_URL,
'hash': self.hashing_func(imagefilename),
}
content = "p { background: url('../../img/python.png#foo') }"
output = "p { background: url('%(url)simg/python.png?%(hash)s#foo') }" % params
filter = CssAbsoluteFilter(content)
self.assertEqual(output, filter.input(filename=filename, basename='css/url/test.css'))
settings.COMPRESS_URL = params['url'] = 'http://media.example.com/'
filter = CssAbsoluteFilter(content)
filename = os.path.join(settings.COMPRESS_ROOT, 'css/url/test.css')
output = "p { background: url('%(url)simg/python.png?%(hash)s#foo') }" % params
self.assertEqual(output, filter.input(filename=filename, basename='css/url/test.css'))
def test_css_absolute_filter_https(self):
filename = os.path.join(settings.COMPRESS_ROOT, 'css/url/test.css')
imagefilename = os.path.join(settings.COMPRESS_ROOT, 'img/python.png')