From 78ec6478ce4663d37beb40345a0703ea97e64df1 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Wed, 26 Jul 2017 16:38:17 -0700 Subject: [PATCH] fix(anchors-with-no-rel): ignore same origin links (#2749) * fix(anchors-with-no-rel): ignore same origin links * smokehouse expectation printing bug --- .../test/smokehouse/dobetterweb/dbw-expectations.js | 4 ++-- lighthouse-cli/test/smokehouse/smokehouse.js | 2 +- .../audits/dobetterweb/external-anchors-use-rel-noopener.js | 2 +- .../gatherers/dobetterweb/anchors-with-no-rel-noopener.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js b/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js index 196a0f03ef41..fd3045297261 100644 --- a/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js +++ b/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js @@ -42,12 +42,12 @@ module.exports = [ 'If they are not used as hyperlinks, consider removing the _blank target.', extendedInfo: { value: { - length: 3 + length: 2 } }, details: { items: { - length: 3 + length: 2 } } }, diff --git a/lighthouse-cli/test/smokehouse/smokehouse.js b/lighthouse-cli/test/smokehouse/smokehouse.js index a65ec9bb7675..0c214a42bd73 100755 --- a/lighthouse-cli/test/smokehouse/smokehouse.js +++ b/lighthouse-cli/test/smokehouse/smokehouse.js @@ -163,7 +163,7 @@ function findDifference(path, actual, expected) { const expectedValue = expected[key]; if (!(key in actual)) { - return {keyPath, undefined, expectedValue}; + return {path: keyPath, actual: undefined, expected: expectedValue}; } const actualValue = actual[key]; diff --git a/lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js b/lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js index a2809b935cd5..4e5fc5290b83 100644 --- a/lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js +++ b/lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js @@ -39,7 +39,7 @@ class ExternalAnchorsUseRelNoopenerAudit extends Audit { const failingAnchors = artifacts.AnchorsWithNoRelNoopener .filter(anchor => { try { - return anchor.href === '' || new URL(anchor.href).host !== pageHost; + return new URL(anchor.href).host !== pageHost; } catch (err) { debugString = 'Lighthouse was unable to determine the destination ' + 'of some anchor tags. If they are not used as hyperlinks, ' + diff --git a/lighthouse-core/gather/gatherers/dobetterweb/anchors-with-no-rel-noopener.js b/lighthouse-core/gather/gatherers/dobetterweb/anchors-with-no-rel-noopener.js index a89b4399ae8e..34b209f7f578 100644 --- a/lighthouse-core/gather/gatherers/dobetterweb/anchors-with-no-rel-noopener.js +++ b/lighthouse-core/gather/gatherers/dobetterweb/anchors-with-no-rel-noopener.js @@ -19,7 +19,7 @@ class AnchorsWithNoRelNoopener extends Gatherer { const selector = 'a[target="_blank"]:not([rel~="noopener"])'; const elements = getElementsInDocument(selector); return elements.map(node => ({ - href: node.getAttribute('href'), + href: node.href, rel: node.getAttribute('rel'), target: node.getAttribute('target') }));