Easier to understand css offenders

This commit is contained in:
Gaël Métais
2015-05-04 17:03:59 +02:00
parent 76fb50473f
commit 604857648b
+12 -3
View File
@@ -390,11 +390,20 @@ var policies = {
return {
count: offenders.length,
list: offenders.map(function(offender) {
if (offender === '[inline CSS] (Empty CSS was provided)') {
return {
error: 'Empty style tag',
file: null,
line: null,
column: null
};
}
var parts = /^(?:(?:<([^ \(]*)>|\[inline CSS\]) ?)?(?:\((((?! @ ).)*)(?: @ (\d+):(\d+))?\))?$/.exec(offender);
if (parts) {
return {
error: parts[2],
error: parts[2] || 'Unknown parsing error',
file: parts[1] || null,
line: (parts[4] && parts[5]) ? parseInt(parts[4], 10) : null,
column: (parts[4] && parts[5]) ? parseInt(parts[5], 10) : null
@@ -406,11 +415,11 @@ var policies = {
if (parts) {
return {
error: parts[1],
error: parts[1] || 'Unknown parsing error',
file: parts[2] || null,
line: parseInt(parts[3], 10),
column: parseInt(parts[4], 10)
}
};
}