fixed compression of CSS files with both non-ASCII characters and URLs
This commit is contained in:
@@ -25,7 +25,7 @@ class CssAbsoluteFilter(FilterBase):
|
||||
url = url.strip(' \'"')
|
||||
if url.startswith('http://') or url.startswith('/'):
|
||||
return "url('%s')" % url
|
||||
full_url = '/'.join([self.directory_name, url])
|
||||
full_url = '/'.join([str(self.directory_name), url])
|
||||
full_url = os.path.normpath(full_url)
|
||||
if self.has_http:
|
||||
full_url = "http://%s" % full_url
|
||||
|
||||
@@ -138,6 +138,9 @@ class CssMediaTestCase(TestCase):
|
||||
|
||||
|
||||
class TemplatetagTestCase(TestCase):
|
||||
def setUp(self):
|
||||
settings.COMPRESS = True
|
||||
|
||||
def render(self, template_string, context_dict=None):
|
||||
"""A shortcut for testing template output."""
|
||||
if context_dict is None:
|
||||
@@ -158,6 +161,15 @@ class TemplatetagTestCase(TestCase):
|
||||
out = u'<link rel="stylesheet" href="/media/CACHE/css/f7c661b7a124.css" type="text/css" media="all" charset="utf-8">'
|
||||
self.assertEqual(out, self.render(template, context))
|
||||
|
||||
def test_nonascii_css_tag(self):
|
||||
template = u"""{% load compress %}{% compress css %}
|
||||
<link rel="stylesheet" href="{{ MEDIA_URL }}css/nonasc.css" type="text/css" charset="utf-8">
|
||||
{% endcompress %}
|
||||
"""
|
||||
context = { 'MEDIA_URL': settings.MEDIA_URL }
|
||||
out = '<link rel="stylesheet" href="/media/CACHE/css/fc35bb10bce9.css" type="text/css" media="all" charset="utf-8">'
|
||||
self.assertEqual(out, self.render(template, context))
|
||||
|
||||
def test_js_tag(self):
|
||||
template = u"""{% load compress %}{% compress js %}
|
||||
<script src="{{ MEDIA_URL }}js/one.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
2
tests/media/css/nonasc.css
Normal file
2
tests/media/css/nonasc.css
Normal file
@@ -0,0 +1,2 @@
|
||||
p { background: url( '../../images/test.png' ); }
|
||||
.byline:before { content: " — "; }
|
||||
Reference in New Issue
Block a user