Fixes #107 - data URIs in imported stylesheets.
authorGoalSmashers <jakub@goalsmashers.com>
Mon, 27 May 2013 21:20:04 +0000 (23:20 +0200)
committerGoalSmashers <jakub@goalsmashers.com>
Mon, 27 May 2013 21:20:04 +0000 (23:20 +0200)
lib/clean.js
test/data/partials/five.css [new file with mode: 0644]
test/unit-test.js

index e0cd5b6..d55930a 100644 (file)
@@ -432,7 +432,7 @@ var CleanCSS = {
 
       tempData.push(data.substring(cursor, nextStart));
       var url = data.substring(nextStart + 4, nextEnd).replace(/['"]/g, '');
-      if (url[0] != '/' && url.substring(url.length - 4) != '.css') {
+      if (url[0] != '/' && url.indexOf('data:') != 0 && url.substring(url.length - 4) != '.css') {
         url = path.relative(toBase, path.join(fromBase, url)).replace(/\\/g, '/');
       }
       tempData.push('url(' + url + ')');
diff --git a/test/data/partials/five.css b/test/data/partials/five.css
new file mode 100644 (file)
index 0000000..4ac4c02
--- /dev/null
@@ -0,0 +1 @@
+.five{background:url(data:image/jpeg;base64,/9j/)}
index 99611cb..b460510 100644 (file)
@@ -816,6 +816,10 @@ title']",
     'of a file with an absolute resource path': [
       "@import url(test/data/partials/four.css);",
       ".four{background-image:url(/partials/extra/down.gif)}",
+    ],
+    'of a file with a resource URI': [
+      "@import url(test/data/partials/five.css);",
+      ".five{background:url(data:image/jpeg;base64,/9j/)}"
     ]
   }),
   '@import with absolute paths': cssContext({