Skip to content

Commit

Permalink
core(is-crawlable): always ignore mailto anchors (#11554)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenyu committed Oct 12, 2020
1 parent 8f7ade1 commit 7e01883
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lighthouse-core/audits/seo/crawlable-anchors.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class CrawlableAnchors extends Audit {
role = role.trim();

if (role.length > 0) return;
// Ignore mailto links even if they use one of the failing patterns. See https://github.com/GoogleChrome/lighthouse/issues/11443#issuecomment-694898412
if (rawHref.startsWith('mailto:')) return;

const windowLocationRegExp = /window\.location=/;
const windowOpenRegExp = /window\.open\(/;
Expand Down
8 changes: 8 additions & 0 deletions lighthouse-core/test/audits/seo/crawlable-anchors-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,12 @@ describe('SEO: Crawlable anchors audit', () => {
assert.equal(auditResult, 1, `'${onclickVariation}' should pass the audit`);
}
});

it('handles window.open in an onclick attribute and mailto: in a href attribute', () => {
assert.equal(
runAudit({rawHref: 'mailto:name@example.com', onclick: 'window.open()'}),
1,
'window.open in an onclick and mailto: in a href is a pass'
);
});
});

0 comments on commit 7e01883

Please sign in to comment.