@@ -12,41 +12,37 @@ export const linkCompiler = ({
1212 const attrs = [ ] ;
1313 const text = this . parser . parseInline ( tokens ) || '' ;
1414 const { str, config } = getAndRemoveConfig ( title ) ;
15+ const isAbsolute = isAbsolutePath ( href ) ;
16+ const isNotCompilable = compiler . _matchNotCompileLink ( href ) ;
17+ const isMailto = href . startsWith ( 'mailto:' ) ;
18+
1519 linkTarget = config . target || linkTarget ;
1620 linkRel =
1721 linkTarget === '_blank'
1822 ? compiler . config . externalLinkRel || 'noopener'
1923 : '' ;
2024 title = str ;
2125
22- if (
23- ! isAbsolutePath ( href ) &&
24- ! compiler . _matchNotCompileLink ( href ) &&
25- ! config . ignore
26- ) {
26+ if ( ! isAbsolute && ! isNotCompilable && ! config . ignore ) {
2727 if ( href === compiler . config . homepage ) {
2828 href = 'README' ;
2929 }
30-
3130 href = router . toURL ( href , null , router . getCurrentPath ( ) ) ;
3231
33- if ( config . target ) {
34- href . indexOf ( 'mailto:' ) !== 0 && attrs . push ( `target="${ linkTarget } "` ) ;
32+ if ( config . target && ! isMailto ) {
33+ attrs . push ( `target="${ linkTarget } "` ) ;
3534 }
3635 } else {
37- if ( ! isAbsolutePath ( href ) && href . startsWith ( './' ) ) {
38- href = router
39- . toURL ( href , null , router . getCurrentPath ( ) )
40- . replace ( / ^ # \/ / , '/' ) ;
36+ if ( ! isAbsolute && ! isNotCompilable && href . startsWith ( './' ) ) {
37+ href = router . toURL ( href , null , router . getCurrentPath ( ) ) . replace ( / ^ # \/ / , '/' ) ;
38+ }
39+
40+ if ( ! isMailto ) {
41+ attrs . push ( `target="${ linkTarget } "` ) ;
42+ if ( linkRel !== '' ) {
43+ attrs . push ( `rel="${ linkRel } "` ) ;
44+ }
4145 }
42- attrs . push ( href . indexOf ( 'mailto:' ) === 0 ? '' : `target="${ linkTarget } "` ) ;
43- attrs . push (
44- href . indexOf ( 'mailto:' ) === 0
45- ? ''
46- : linkRel !== ''
47- ? ` rel="${ linkRel } "`
48- : '' ,
49- ) ;
5046 }
5147
5248 if ( config . disabled ) {
0 commit comments