File tree 2 files changed +13
-7
lines changed
2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change 10
10
<a v-if =" githubLink"
11
11
:href =" githubLink"
12
12
class =" github-link"
13
- target =" _blank" >
13
+ target =" _blank"
14
+ rel =" noopener" >
14
15
Github
15
16
<OutboundLink />
16
17
</a >
Original file line number Diff line number Diff line change @@ -14,12 +14,8 @@ module.exports = md => {
14
14
const isExternal = / ^ h t t p s ? : / . test ( href )
15
15
const isSourceLink = / ( \/ | \. m d | \. h t m l ) ( # [ \w - ] * ) ? $ / . test ( href )
16
16
if ( isExternal ) {
17
- const targetIndex = token . attrIndex ( 'target' )
18
- if ( targetIndex < 0 ) {
19
- token . attrPush ( [ 'target' , '_blank' ] )
20
- } else {
21
- token . attrs [ targetIndex ] [ 1 ] = '_blank'
22
- }
17
+ addAttr ( token , 'target' , '_blank' )
18
+ addAttr ( token , 'rel' , 'noopener' )
23
19
} else if ( isSourceLink ) {
24
20
hasOpenRouterLink = true
25
21
tokens [ idx ] = toRouterLink ( token , link )
@@ -58,3 +54,12 @@ module.exports = md => {
58
54
return self . renderToken ( tokens , idx , options )
59
55
}
60
56
}
57
+
58
+ function addAttr ( token , name , val ) {
59
+ const targetIndex = token . attrIndex ( name )
60
+ if ( targetIndex < 0 ) {
61
+ token . attrPush ( [ name , val ] )
62
+ } else {
63
+ token . attrs [ targetIndex ] [ 1 ] = val
64
+ }
65
+ }
You can’t perform that action at this time.
0 commit comments