fix: Add rel="noopener noreferrer" to links when openLinksInNewWindow is on

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

Closes #670
This commit is contained in:
Jammerware 2019-11-02 14:58:07 -04:00 committed by Estevão Soares dos Santos
parent 33bba54535
commit caab5bb7bc
5 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>