From: GoalSmashers Date: Thu, 5 Sep 2013 10:44:20 +0000 (+0200) Subject: Fixes issue #141 - broken url rebasing on Windows. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=0464106b282992a05481c95554f8f1064a847144;p=clean-css.git Fixes issue #141 - broken url rebasing on Windows. --- diff --git a/lib/images/url-rebase.js b/lib/images/url-rebase.js index b3574705..c5a00e21 100644 --- a/lib/images/url-rebase.js +++ b/lib/images/url-rebase.js @@ -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); } }; diff --git a/lib/images/url-rewriter.js b/lib/images/url-rewriter.js index 37a9aa29..6903edc7 100644 --- a/lib/images/url-rewriter.js +++ b/lib/images/url-rewriter.js @@ -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)) diff --git a/test/binary-test.js b/test/binary-test.js index 928eee27..fde7e9d7 100644 --- a/test/binary-test.js +++ b/test/binary-test.js @@ -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': {