Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(loader): trim unquoted import urls #783

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/loader.js
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
Expand Up @@ -13,6 +13,12 @@ describe("import", function() {
], "", {
"./test.css": [[2, ".test{a: b}", ""]]
});
test("import with trailing whitespace", "@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