Skip to content

Commit 21fcddf

Browse files
joelgallantmichael-ciniawsky
authored andcommitted
fix(loader): trim unquoted import urls (#783)
1 parent 67b2f20 commit 21fcddf

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/loader.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ module.exports = function(content, map) {
4949
var importUrlPrefix = getImportPrefix(this, query);
5050

5151
var alreadyImported = {};
52-
var importJs = result.importItems.filter(function(imp) {
52+
var importJs = result.importItems.map(function(imp) {
53+
// fixes #781 when importing `url(filename.css )`
54+
imp.url = imp.url.trim();
55+
return imp;
56+
}).filter(function(imp) {
5357
if(!imp.mediaQuery) {
5458
if(alreadyImported[imp.url])
5559
return false;

test/importTest.js

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ describe("import", function() {
1313
], "", {
1414
"./test.css": [[2, ".test{a: b}", ""]]
1515
});
16+
test("import with trailing whitespace", "@import url(test.css );\n.class { a: b c d; }", [
17+
[2, ".test{a: b}", ""],
18+
[1, ".class { a: b c d; }", ""]
19+
], "", {
20+
"./test.css": [[2, ".test{a: b}", ""]]
21+
});
1622
test("import camelcase", "@IMPORT url(test.css);\n.class { a: b c d; }", [
1723
[2, ".test{a: b}", ""],
1824
[1, ".class { a: b c d; }", ""]

0 commit comments

Comments
 (0)