Fix rare Cannot read property '1' of null error

This commit is contained in:
Gaël Métais
2015-11-26 09:55:21 +01:00
parent e3d378a4ba
commit 4f9589fb6b
+4 -2
View File
@@ -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) {