From 4f9589fb6b48d91338eb314c9cd1b8e0364b8cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Thu, 26 Nov 2015 09:55:21 +0100 Subject: [PATCH] Fix rare Cannot read property '1' of null error --- lib/tools/colorDiff.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tools/colorDiff.js b/lib/tools/colorDiff.js index bf9cdae..d7217d6 100644 --- a/lib/tools/colorDiff.js +++ b/lib/tools/colorDiff.js @@ -46,7 +46,9 @@ var colorDiff = function() { var deduplicatedColors = {}; parsedOffenders.forEach(function(color) { - deduplicatedColors[color] = color; + if (color !== null) { + deduplicatedColors[color] = color; + } }); return Object.keys(deduplicatedColors).map(this.parseColor); @@ -54,7 +56,7 @@ var colorDiff = function() { this.parseOffender = function(offender) { var regexResult = /^(.*) \(\d+ times\)$/.exec(offender); - return regexResult[1]; + return regexResult ? regexResult[1] : null; }; this.parseColor = function(color) {