Skip to content

Commit

Permalink
fix: Add rel="noopener noreferrer" to links when openLinksInNewWindow…
Browse files Browse the repository at this point in the history
… is on

Add rel="noreferrer" to links when openLinksInNewWindow is on. Also add noopener when openLinksInNewWindow is on.

Closes #670
  • Loading branch information
jammerware authored and tivie committed Nov 2, 2019
1 parent 33bba54 commit caab5bb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/subParsers/makehtml/links.js
Expand Up @@ -117,7 +117,7 @@
// to external links. Hash links (#) open in same page
if (options.openLinksInNewWindow && !/^#/.test(url)) {
// escaped _
target = ' target="¨E95Eblank"';
target = ' rel="noopener noreferrer" target="¨E95Eblank"';
}

// Text can be a markdown element, so we run through the appropriate parsers
Expand Down
@@ -1,2 +1,2 @@
<p>My <a href="http://example.com" target="_blank">link</a> is <em>important</em></p>
<p>My <a href="http://example.com" target="_blank">link</a> is <strong>important</strong></p>
<p>My <a href="http://example.com" rel="noopener noreferrer" target="_blank">link</a> is <em>important</em></p>
<p>My <a href="http://example.com" rel="noopener noreferrer" target="_blank">link</a> is <strong>important</strong></p>
@@ -1,2 +1,2 @@
<p><a href="www.google.com" target="_blank">foo</a></p>
<p>a link <a href="http://www.google.com" target="_blank">http://www.google.com</a></p>
<p><a href="www.google.com" rel="noopener noreferrer" target="_blank">foo</a></p>
<p>a link <a href="http://www.google.com" rel="noopener noreferrer" target="_blank">http://www.google.com</a></p>
@@ -1,2 +1,2 @@
<p><a href="www.google.com" target="_blank">foo</a></p>
<p>a link <a href="http://www.google.com" target="_blank">http://www.google.com</a></p>
<p><a href="www.google.com" rel="noopener noreferrer" target="_blank">foo</a></p>
<p>a link <a href="http://www.google.com" rel="noopener noreferrer" target="_blank">http://www.google.com</a></p>
@@ -1 +1 @@
<p>this is <a href="http://www.google.com" target="_blank">http://www.google.com</a> autolink</p>
<p>this is <a href="http://www.google.com" rel="noopener noreferrer" target="_blank">http://www.google.com</a> autolink</p>

0 comments on commit caab5bb

Please sign in to comment.