-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core(audit): Ignore href=javascript:.* for rel=noopener audit #3574
core(audit): Ignore href=javascript:.* for rel=noopener audit #3574
Conversation
d9b2a37
to
d05f19c
Compare
ca1228c
to
b661b02
Compare
@patrickhulce I'm not sure how to fix the commitlint error. It doesn't seem to consider rebased commits. Everything else seems to be passing. |
@@ -47,6 +47,10 @@ class ExternalAnchorsUseRelNoopenerAudit extends Audit { | |||
return true; | |||
} | |||
}) | |||
.filter(anchor => { | |||
// Ignore href's that do not redirect to a new url | |||
return !/javascript:.*/.test(anchor.href); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't this be better?
return !/^javascript:/.test(anchor.href);
just to make sure the string starts with javascript:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wardpeet Thats a good idea. Makes it much more robust. Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -47,6 +47,10 @@ class ExternalAnchorsUseRelNoopenerAudit extends Audit { | |||
return true; | |||
} | |||
}) | |||
.filter(anchor => { | |||
// Ignore href's that do not redirect to a new url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore href's that are not real links
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -47,6 +47,10 @@ class ExternalAnchorsUseRelNoopenerAudit extends Audit { | |||
return true; | |||
} | |||
}) | |||
.filter(anchor => { | |||
// Ignore href's that do not redirect to a new url | |||
return !/^javascript:/.test(anchor.href); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use startsWith
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@paulirish I was going through #3490 and based on the tests (https://github.com/GoogleChrome/lighthouse/pull/3490/files#diff-8f19451b89a25fa6b1259f337761d2cbR59) I think we should be doing a case insensitive check of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be doing a case insensitive check of javascript:, unless i'm mistaken. Thoughts?
looks like it is case insensitive, so sounds good
@brendankenny I meant that |
Bump. |
we could do @karanjthakkar Chrome Dev Summit just happend so the team had some other priorities. Thanks for being so patient! |
@wardpeet So sorry about that. It totally slipped my mind. I appreciate you circling back with a reply. I've made the changes 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks @karanjthakkar!
@@ -47,6 +47,14 @@ class ExternalAnchorsUseRelNoopenerAudit extends Audit { | |||
return true; | |||
} | |||
}) | |||
.filter(anchor => { | |||
// Ignore href's that are not real links | |||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we could probably simplify this to !anchor.href || !anchor.href.toLowerCase().startsWith('javascript:')
Fixes #3079
PS: Happy to close this if @akonchady has another implementation in place already.#3079 (comment)