From 2829c8de3897d2b51f411b0b3854f6b1e72b2e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Fri, 5 Sep 2014 11:52:52 +0200 Subject: [PATCH] Fix rare bug on duplicated queries --- app/public/scripts/resultsCtrl.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/public/scripts/resultsCtrl.js b/app/public/scripts/resultsCtrl.js index 3980012..279a743 100644 --- a/app/public/scripts/resultsCtrl.js +++ b/app/public/scripts/resultsCtrl.js @@ -57,9 +57,12 @@ app.controller('ResultsCtrl', function ($scope) { // Read all the duplicated queries and calculate a more appropriated score $scope.duplicatedQueriesCountAll = 0; if ($scope.phantomasResults.offenders.DOMqueriesDuplicated) { - var regex = /^{.*}: (\d+) queries$/; + var regex = /^{.*}: *(\d+) queries$/; $scope.phantomasResults.offenders.DOMqueriesDuplicated.forEach(function(query) { - $scope.duplicatedQueriesCountAll += parseInt(regex.exec(query)[1], 10) - 1; + var regexResult = regex.exec(query); + if (regexResult) { + $scope.duplicatedQueriesCountAll += parseInt(regexResult[1], 10) - 1; + } }); }