From 2bc94aba8b0ffc408d8b4fc3f8dc084c889438f7 Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Tue, 3 Oct 2017 23:05:57 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20don=E2=80=99t=20choke=20on=20=E2=80=93an?= =?UTF-8?q?d=20report=E2=80=93=20missing=20KB=20links?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/report/axe2ace.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/report/axe2ace.js b/src/report/axe2ace.js index d9a09d44..03d4b113 100644 --- a/src/report/axe2ace.js +++ b/src/report/axe2ace.js @@ -72,11 +72,18 @@ function axe2ace(spineItem, axeResults) { .withTestSubject(spineItem.relpath, spineItem.title); // process axe's individual checks for a single content document axeResults.violations.forEach((violation) => { + const kbURL = (kbMap.map.hasOwnProperty(violation.id)) + ? kbMap.baseUrl + kbMap.map[violation.id].url + : kbMap.baseUrl; + const kbTitle = (kbMap.map.hasOwnProperty(violation.id)) + ? kbMap.map[violation.id].title + : 'Unknown'; + if (kbTitle == 'Unknown') winston.verbose(`Couldn’t find KB key for rule '${violation.id}'`) const test = new builders.TestBuilder() .withImpact(violation.impact) .withTitle(violation.id) .withDescription(violation.description) - .withHelp(kbMap.baseUrl + kbMap.map[violation.id].url, kbMap.map[violation.id].title) + .withHelp(kbURL, kbTitle) .build(); violation.nodes.forEach(node => assertion.withAssertion( new builders.AssertionBuilder()