From: Jakub Pawlowicz Date: Fri, 29 May 2015 08:46:02 +0000 (+0100) Subject: Fixes #580 - mixed import processing. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=9aabe4273f762c48888bca2ce005c865c52c7f51;p=clean-css.git Fixes #580 - mixed import processing. This is related to #570 when a no-url imports are mixed with url ones. --- diff --git a/History.md b/History.md index b6ad8245..52596563 100644 --- a/History.md +++ b/History.md @@ -19,6 +19,7 @@ * Fixed issue [#575](https://github.com/jakubpawlowicz/clean-css/issues/575) - missing directory as a `target`. * Fixed issue [#577](https://github.com/jakubpawlowicz/clean-css/issues/577) - `background-clip` into shorthand. * Fixed issue [#579](https://github.com/jakubpawlowicz/clean-css/issues/579) - `background-origin` into shorthand. +* Fixed issue [#580](https://github.com/jakubpawlowicz/clean-css/issues/580) - mixed `@import` processing. * Fixed issue [#582](https://github.com/jakubpawlowicz/clean-css/issues/582) - overriding with prefixed values. * Fixed issue [#583](https://github.com/jakubpawlowicz/clean-css/issues/583) - URL quoting for SVG data. diff --git a/lib/urls/reduce.js b/lib/urls/reduce.js index 84555c80..ded0bf72 100644 --- a/lib/urls/reduce.js +++ b/lib/urls/reduce.js @@ -99,8 +99,10 @@ function byImport(data, context, callback) { tempData.push(data.substring(cursor, nextStart)); nextEnd = data.indexOf(withQuote, nextStart + 1); - if (nextEnd == -1) + if (nextEnd == -1) { + cursor = nextStart; break; + } var url = data.substring(nextStart, nextEnd + 1); callback(url, tempData); diff --git a/test/module-test.js b/test/module-test.js index 02239874..2c1f64dc 100644 --- a/test/module-test.js +++ b/test/module-test.js @@ -578,6 +578,18 @@ vows.describe('module tests').addBatch({ 'should give right output': function (minified) { assert.equal(minified.styles, '.one{color:red}.three{color:#0f0}.four{color:#00f}.two{color:#fff}'); } + }, + 'with two import URLs when one is a string plus a callback 123': { + 'topic': function () { + new CleanCSS().minify({ + 'main.css': { + styles: '@import "test/fixtures/partials/one.css";\n@import url(test/fixtures/partials/three.css);' + } + }, this.callback); + }, + 'should give right output': function (error, minified) { + assert.equal(minified.styles, '.one{color:red}.three{background-image:url(test/fixtures/partials/extra/down.gif)}'); + } } }, 'with remote paths': {