mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
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:
parent
33bba54535
commit
caab5bb7bc
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user