فهرست منبع

Better parsing of cssParsingErrors' offenders

Gaël Métais 10 سال پیش
والد
کامیت
ffee3b225f
1فایلهای تغییر یافته به همراه20 افزوده شده و 7 حذف شده
  1. 20 7
      lib/metadata/policies.js

+ 20 - 7
lib/metadata/policies.js

@@ -392,18 +392,31 @@ var policies = {
                 list: offenders.map(function(offender) {
                     var parts = /^(?:(?:<([^ \(]*)>|\[inline CSS\]) ?)?(?:\((((?! @ ).)*)(?: @ (\d+):(\d+))?\))?$/.exec(offender);
 
-                    if (!parts) {
-                        debug('cssParsingErrors offenders transform function error with "%s"', offender);
+                    if (parts) {
                         return {
-                            parseError: offender
+                            error: parts[2],
+                            file: parts[1] || null,
+                            line: (parts[4] && parts[5]) ? parseInt(parts[4], 10) : null,
+                            column: (parts[4] && parts[5]) ? parseInt(parts[5], 10) : null
                         };
                     }
 
+                    // Try another syntax
+                    parts = /^(.*) <(.*)> @ (\d+):(\d+)$/.exec(offender);
+
+                    if (parts) {
+                        return {
+                            error: parts[1],
+                            file: parts[2] || null,
+                            line: parseInt(parts[3], 10),
+                            column: parseInt(parts[4], 10)
+                        }
+                    }
+
+
+                    debug('cssParsingErrors offenders transform function error with "%s"', offender);
                     return {
-                        error: parts[2],
-                        file: parts[1] || null,
-                        line: (parts[4] && parts[5]) ? parseInt(parts[4], 10) : null,
-                        column: (parts[4] && parts[5]) ? parseInt(parts[5], 10) : null
+                        parseError: offender
                     };
                 })
             };