Skip to content
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

Add extension to ensure that rel="noopener" is added when target="_blank" #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hamiltonweb
Copy link

Detectify identifies a risk when a link is target="_blank".
A rel="noopener" attribute should be added.

https://support.detectify.com/customer/portal/articles/2792257-external-links-using-target-_blank-

Copy link
Contributor

@alanwthom alanwthom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be returning "value" instead of an empty string if the parameter isn't "_blank" (i.e. "_self")? Should we look to do an insensitive case match as well (although unlikely someone would submit "_Blank" I admit)?

@owen-roberts
Copy link
Contributor

Can we add some documentation & if possible some unit tests?

@owen-roberts
Copy link
Contributor

I've recently had the need to split this into two separate methods for a project.
One extension method for the Link class supplied in Umbraco.Web.Models which is called using myLink.Target(), and another method which works on a string, called using myStringTarget.AsLinkTarget().

I may update the contrib library with both of these instead of LinkTarget method currently supplied.
Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants