소스 검색

Fix rare Cannot read property '1' of null error

Gaël Métais 9 년 전
부모
커밋
4f9589fb6b
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      lib/tools/colorDiff.js

+ 4 - 2
lib/tools/colorDiff.js

@@ -46,7 +46,9 @@ var colorDiff = function() {
         var deduplicatedColors = {};
         var deduplicatedColors = {};
 
 
         parsedOffenders.forEach(function(color) {
         parsedOffenders.forEach(function(color) {
-            deduplicatedColors[color] = color;
+            if (color !== null) {
+                deduplicatedColors[color] = color;
+            }
         });
         });
 
 
         return Object.keys(deduplicatedColors).map(this.parseColor);
         return Object.keys(deduplicatedColors).map(this.parseColor);
@@ -54,7 +56,7 @@ var colorDiff = function() {
 
 
     this.parseOffender = function(offender) {
     this.parseOffender = function(offender) {
         var regexResult = /^(.*) \(\d+ times\)$/.exec(offender);
         var regexResult = /^(.*) \(\d+ times\)$/.exec(offender);
-        return regexResult[1];
+        return regexResult ? regexResult[1] : null;
     };
     };
 
 
     this.parseColor = function(color) {
     this.parseColor = function(color) {