Fixes issue #141 - broken url rebasing on Windows.
authorGoalSmashers <jakub@goalsmashers.com>
Thu, 5 Sep 2013 10:44:20 +0000 (12:44 +0200)
committerGoalSmashers <jakub@goalsmashers.com>
Thu, 5 Sep 2013 10:44:20 +0000 (12:44 +0200)
lib/images/url-rebase.js
lib/images/url-rewriter.js
test/binary-test.js

index b357470..c5a00e2 100644 (file)
@@ -16,9 +16,6 @@ module.exports = {
     if (rebaseOpts.relative)
       rebaseOpts.toBase = path.resolve(path.dirname(options.target));
 
-    if (rebaseOpts.absolute && (!rebaseOpts.fromBase || !rebaseOpts.toBase))
-      return data;
-
     return UrlRewriter.process(data, rebaseOpts);
   }
 };
index 37a9aa2..6903edc 100644 (file)
@@ -41,6 +41,9 @@ module.exports = {
     if (!options.absolute && !options.relative)
       throw new Error('Relative url found: \'' + url + '\' but there is no way to resolve it (hint: use `root` or `output` options)');
 
+    if (!options.fromBase || !options.toBase)
+      return url;
+
     if (options.absolute) {
       rebased = path
         .resolve(path.join(options.fromBase, url))
index 928eee2..fde7e9d 100644 (file)
@@ -177,6 +177,15 @@ exports.commandsSuite = vows.describe('binary commands').addBatch({
       teardown: function() {
         deleteFile('./base2-min.css');
       }
+    }),
+    'piped with output': pipedContext('a{background:url(test/data/partials/extra/down.gif)}', '-o base3-min.css', {
+      'should keep paths as they are': function() {
+        var minimized = readFile('base3-min.css');
+        assert.equal(minimized, 'a{background:url(test/data/partials/extra/down.gif)}');
+      },
+      teardown: function() {
+        deleteFile('base3-min.css');
+      }
     })
   },
   'complex import and url rebasing': {