Skip to content

Commit 4b1d43a

Browse files
test: coverange
1 parent bc19ddd commit 4b1d43a

File tree

6 files changed

+198
-43
lines changed

6 files changed

+198
-43
lines changed

src/plugins/postcss-import-parser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export default postcss.plugin(pluginName, (options) => (css, result) => {
5050
if (nodes[0].type === 'string') {
5151
isStringValue = true;
5252
url = nodes[0].value;
53-
} else if (nodes[0].type === 'function') {
53+
}
54+
55+
if (nodes[0].type === 'function') {
5456
// Invalid function - `@import nourl(test.css);`
5557
if (nodes[0].value.toLowerCase() !== 'url') {
5658
result.warn(`Unable to find uri in "${atRule.toString()}"`, {

src/plugins/postcss-url-parser.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ function getNodeFromUrlFunc(node) {
2020
function ruleValidate(rule, decl, result, options) {
2121
// https://www.w3.org/TR/css-syntax-3/#typedef-url-token
2222
if (rule.url.replace(/^[\s]+|[\s]+$/g, '').length === 0) {
23-
result.warn(
24-
`Unable to find uri in '${decl ? decl.toString() : decl.value}'`,
25-
{ node: decl }
26-
);
23+
result.warn(`Unable to find uri in '${decl.toString()}'`, { node: decl });
2724

2825
return false;
2926
}
@@ -139,13 +136,7 @@ export default postcss.plugin(pluginName, (options) => (css, result) => {
139136
const replacementsMap = new Map();
140137
const urlToHelper = require.resolve('../runtime/getUrl.js');
141138

142-
let parsedResults;
143-
144-
try {
145-
parsedResults = await walkCssAsync(css, result, options);
146-
} catch (error) {
147-
reject(error);
148-
}
139+
const parsedResults = await walkCssAsync(css, result, options);
149140

150141
if (parsedResults.length === 0) {
151142
resolve();
@@ -169,9 +160,7 @@ export default postcss.plugin(pluginName, (options) => (css, result) => {
169160
// 'CSS_LOADER_GET_URL_IMPORT'
170161
order: 2,
171162
importName: '___CSS_LOADER_GET_URL_IMPORT___',
172-
url: options.urlHandler
173-
? options.urlHandler(urlToHelper)
174-
: urlToHelper,
163+
url: options.urlHandler(urlToHelper),
175164
index,
176165
},
177166
});
@@ -236,9 +225,7 @@ export default postcss.plugin(pluginName, (options) => (css, result) => {
236225
// 'CSS_LOADER_URL_IMPORT'
237226
order: 3,
238227
importName,
239-
url: options.urlHandler
240-
? options.urlHandler(resolvedUrl)
241-
: resolvedUrl,
228+
url: options.urlHandler(resolvedUrl),
242229
index: currentIndex,
243230
},
244231
});

0 commit comments

Comments
 (0)