Fix Windows path separator issues
This commit is contained in:
@@ -50,7 +50,7 @@ class CssAbsoluteFilter(FilterBase):
|
|||||||
if local_path.startswith(self.url_path):
|
if local_path.startswith(self.url_path):
|
||||||
local_path = local_path.replace(self.url_path, "", 1)
|
local_path = local_path.replace(self.url_path, "", 1)
|
||||||
# Re-build the local full path by adding root
|
# Re-build the local full path by adding root
|
||||||
filename = os.path.join(self.root, local_path.lstrip(os.sep))
|
filename = os.path.join(self.root, local_path.lstrip('/'))
|
||||||
return os.path.exists(filename) and filename
|
return os.path.exists(filename) and filename
|
||||||
|
|
||||||
def add_suffix(self, url):
|
def add_suffix(self, url):
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ class CompressorTestCase(TestCase):
|
|||||||
|
|
||||||
def test_css_split(self):
|
def test_css_split(self):
|
||||||
out = [
|
out = [
|
||||||
(SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css/one.css'), u'css/one.css', u'<link rel="stylesheet" href="/media/css/one.css" type="text/css" />'),
|
(SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css', u'one.css'), u'css/one.css', u'<link rel="stylesheet" href="/media/css/one.css" type="text/css" />'),
|
||||||
(SOURCE_HUNK, u'p { border:5px solid green;}', None, u'<style type="text/css">p { border:5px solid green;}</style>'),
|
(SOURCE_HUNK, u'p { border:5px solid green;}', None, u'<style type="text/css">p { border:5px solid green;}</style>'),
|
||||||
(SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css/two.css'), u'css/two.css', u'<link rel="stylesheet" href="/media/css/two.css" type="text/css" />'),
|
(SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css', u'two.css'), u'css/two.css', u'<link rel="stylesheet" href="/media/css/two.css" type="text/css" />'),
|
||||||
]
|
]
|
||||||
split = self.css_node.split_contents()
|
split = self.css_node.split_contents()
|
||||||
split = [(x[0], x[1], x[2], self.css_node.parser.elem_str(x[3])) for x in split]
|
split = [(x[0], x[1], x[2], self.css_node.parser.elem_str(x[3])) for x in split]
|
||||||
@@ -80,7 +80,7 @@ class CompressorTestCase(TestCase):
|
|||||||
|
|
||||||
def test_js_split(self):
|
def test_js_split(self):
|
||||||
out = [
|
out = [
|
||||||
(SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'js/one.js'), u'js/one.js', '<script src="/media/js/one.js" type="text/javascript"></script>'),
|
(SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'js', u'one.js'), u'js/one.js', '<script src="/media/js/one.js" type="text/javascript"></script>'),
|
||||||
(SOURCE_HUNK, u'obj.value = "value";', None, '<script type="text/javascript">obj.value = "value";</script>'),
|
(SOURCE_HUNK, u'obj.value = "value";', None, '<script type="text/javascript">obj.value = "value";</script>'),
|
||||||
]
|
]
|
||||||
split = self.js_node.split_contents()
|
split = self.js_node.split_contents()
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ class Html5LibParserTests(ParserTestCase, CompressorTestCase):
|
|||||||
|
|
||||||
def test_css_split(self):
|
def test_css_split(self):
|
||||||
out = [
|
out = [
|
||||||
(SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css/one.css'), u'css/one.css', u'<link href="/media/css/one.css" rel="stylesheet" type="text/css">'),
|
(SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css', u'one.css'), u'css/one.css', u'<link href="/media/css/one.css" rel="stylesheet" type="text/css">'),
|
||||||
(SOURCE_HUNK, u'p { border:5px solid green;}', None, u'<style type="text/css">p { border:5px solid green;}</style>'),
|
(SOURCE_HUNK, u'p { border:5px solid green;}', None, u'<style type="text/css">p { border:5px solid green;}</style>'),
|
||||||
(SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css/two.css'), u'css/two.css', u'<link href="/media/css/two.css" rel="stylesheet" type="text/css">'),
|
(SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css', u'two.css'), u'css/two.css', u'<link href="/media/css/two.css" rel="stylesheet" type="text/css">'),
|
||||||
]
|
]
|
||||||
split = self.css_node.split_contents()
|
split = self.css_node.split_contents()
|
||||||
split = [(x[0], x[1], x[2], self.css_node.parser.elem_str(x[3])) for x in split]
|
split = [(x[0], x[1], x[2], self.css_node.parser.elem_str(x[3])) for x in split]
|
||||||
@@ -55,7 +55,7 @@ class Html5LibParserTests(ParserTestCase, CompressorTestCase):
|
|||||||
|
|
||||||
def test_js_split(self):
|
def test_js_split(self):
|
||||||
out = [
|
out = [
|
||||||
(SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'js/one.js'), u'js/one.js', u'<script src="/media/js/one.js" type="text/javascript"></script>'),
|
(SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'js', u'one.js'), u'js/one.js', u'<script src="/media/js/one.js" type="text/javascript"></script>'),
|
||||||
(SOURCE_HUNK, u'obj.value = "value";', None, u'<script type="text/javascript">obj.value = "value";</script>'),
|
(SOURCE_HUNK, u'obj.value = "value";', None, u'<script type="text/javascript">obj.value = "value";</script>'),
|
||||||
]
|
]
|
||||||
split = self.js_node.split_contents()
|
split = self.js_node.split_contents()
|
||||||
|
|||||||
Reference in New Issue
Block a user