-
-
Notifications
You must be signed in to change notification settings - Fork 607
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: stricter @import
tolerance
#593
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,12 +42,12 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) { | |
} | ||
|
||
if(options.import) { | ||
css.walkAtRules(/import/i, function(rule) { | ||
css.walkAtRules(/^import$/i, function(rule) { | ||
var values = Tokenizer.parseValues(rule.params); | ||
var url = values.nodes[0].nodes[0]; | ||
if(url.type === "url") { | ||
if(url && url.type === "url") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to get the same error handling about malformed URLs for non-existing URLs. This was actually the original error, where I got something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @swernerx can your add tests for this, thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be a new kind of test which tests for throwing errors. We do not do this currently in CSS loader it seems... at least not in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @swernerx we should add tests or avoid this fix here (move to separate issue or PR) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @swernerx oh no 😄 your test was right with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's what I did. Without the new handling it should just throw some hard error. |
||
url = url.url; | ||
} else if(url.type === "string") { | ||
} else if(url && url.type === "string") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? |
||
url = url.value; | ||
} else throw rule.error("Unexpected format " + rule.params); | ||
if (!url.replace(/\s/g, '').length) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/^@import$/i
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-ciniawsky
walkAtRules
already walks only on@something
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The at-sign is not needed here, right.