From 60e31ab8cae307cb923bf6d03b9fad598558da9b Mon Sep 17 00:00:00 2001 From: James Hamilton Date: Thu, 28 Mar 2019 10:21:51 +0000 Subject: [PATCH] Add extension method to ensure that rel="noopener" is added when target="_blank" --- .../Extensions/LinkExtensions.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/storm.umbraco.contrib/Extensions/LinkExtensions.cs diff --git a/src/storm.umbraco.contrib/Extensions/LinkExtensions.cs b/src/storm.umbraco.contrib/Extensions/LinkExtensions.cs new file mode 100644 index 0000000..20a8930 --- /dev/null +++ b/src/storm.umbraco.contrib/Extensions/LinkExtensions.cs @@ -0,0 +1,12 @@ +using System.Web; + +namespace storm.umbraco.contrib.Extensions +{ + public static class LinkExtensions + { + public static IHtmlString LinkTarget(this string value) + { + return (!string.IsNullOrEmpty(value) && value == "_blank") ? new HtmlString(@" target=""_blank"" rel=""noopener""") : new HtmlString(string.Empty); + } + } +}