core(rel=noopener-audit): Only test http/https links#4036
core(rel=noopener-audit): Only test http/https links#4036patrickhulce merged 4 commits intoGoogleChrome:masterfrom
Conversation
|
Fixing the tests now... |
patrickhulce
left a comment
There was a problem hiding this comment.
thanks for the quick patch @sanjsanj!! 👏
would you mind adding a few sample test cases to catch this failure?
the smoke tests file is over here
lighthouse/lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html
Lines 103 to 113 in f49ef06
and unit tests over here
can throw in a check for handling href === null in unit tests and the mail links in both cases
| // Ignore href's that are not real links | ||
| return !anchor.href || !anchor.href.toLowerCase().startsWith('javascript:'); | ||
| }) | ||
| .filter(anchor => anchor.href.toLowerCase().startsWith('http')) |
There was a problem hiding this comment.
probably need a anchor.href && here to be safe
There was a problem hiding this comment.
@patrickhulce I meant to ask about that, it was previously checking for !anchor.href, and the unit tests seem to suggest that's what it's wanting to do, so I've put that back in.
There was a problem hiding this comment.
Unless this unit test is wrong and this audit should ignore anchors without external links, and I presume you need an href to be an external link.
There was a problem hiding this comment.
oh whoops, yeah that's right you can ignore my comment then :)
when glancing I assumed it was there as a null guard for the next case, but I remember now it was intentional
…or the bug that raised this issue
|
@patrickhulce Thanks for the fast feedback! Yup sure, leave it with me I'll get that done asap. |
|
Ok I've added a handful more tests. While I was at it I couldn't resist tidying them up a bit;
|
|
Sorry again, fixing the tests... :) |
|
Sorry, forgot to update after fixing the failing tests but the PR is ready for more feedback when you have time, TY! |
patrickhulce
left a comment
There was a problem hiding this comment.
thanks for jumping in here on this @sanjsanj! congrats on your first contribution!! 🎉 🥇
|
Sweeeet, cheers @patrickhulce ! |
Closes #3714
Only filter anchor links that start with an http protocol for the
rel=noopeneraudit.