Repository navigation
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") { | ||
|
Contributor
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. ?
Contributor
Author
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
Member
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!
Contributor
Author
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
Member
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)
Contributor
Author
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
Member
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
Contributor
Author
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") { | ||
|
Contributor
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$/iUh oh!
There was an error while loading. Please reload this page.
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
walkAtRulesalready 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.