diff --git a/lib/loader.js b/lib/loader.js index b76c86de3..c31d5dead 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -49,7 +49,11 @@ module.exports = function(content, map) { var importUrlPrefix = getImportPrefix(this, query); var alreadyImported = {}; - var importJs = result.importItems.filter(function(imp) { + var importJs = result.importItems.map(function(imp) { + // fixes #781 when importing `url(filename.css )` + imp.url = imp.url.trim(); + return imp; + }).filter(function(imp) { if(!imp.mediaQuery) { if(alreadyImported[imp.url]) return false; diff --git a/test/importTest.js b/test/importTest.js index f3cdba580..3d8b9aa2c 100644 --- a/test/importTest.js +++ b/test/importTest.js @@ -13,6 +13,12 @@ describe("import", function() { ], "", { "./test.css": [[2, ".test{a: b}", ""]] }); + test("import", "@import url(test.css );\n.class { a: b c d; }", [ + [2, ".test{a: b}", ""], + [1, ".class { a: b c d; }", ""] + ], "", { + "./test.css": [[2, ".test{a: b}", ""]] + }); test("import camelcase", "@IMPORT url(test.css);\n.class { a: b c d; }", [ [2, ".test{a: b}", ""], [1, ".class { a: b c d; }", ""]