Skip to content

Commit

Permalink
Trims whitespace in import urls for unquoted imports
Browse files Browse the repository at this point in the history
Fixes #781
  • Loading branch information
joelgallant committed Oct 10, 2018
1 parent 67b2f20 commit a57f8ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions test/importTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; }", ""]
Expand Down

0 comments on commit a57f8ab

Please sign in to comment.