File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ export const linkCompiler = ({
28
28
}
29
29
30
30
href = router . toURL ( href , null , router . getCurrentPath ( ) ) ;
31
+
32
+ if ( config . target ) {
33
+ href . indexOf ( 'mailto:' ) !== 0 && attrs . push ( `target="${ linkTarget } "` ) ;
34
+ }
31
35
} else {
32
36
if ( ! isAbsolutePath ( href ) && href . slice ( 0 , 2 ) === './' ) {
33
37
href =
Original file line number Diff line number Diff line change @@ -253,14 +253,22 @@ describe('render', function () {
253
253
) ;
254
254
} ) ;
255
255
256
- test ( 'target' , async function ( ) {
256
+ test ( 'target for absolute path ' , async function ( ) {
257
257
const output = window . marked ( "[alt text](http://url ':target=_self')" ) ;
258
258
259
259
expect ( output ) . toMatchInlineSnapshot (
260
260
`"<p><a href=\\"http://url\\" target=\\"_self\\" >alt text</a></p>"`
261
261
) ;
262
262
} ) ;
263
263
264
+ test ( 'target for relative path' , async function ( ) {
265
+ const output = window . marked ( "[alt text](/url ':target=_blank')" ) ;
266
+
267
+ expect ( output ) . toMatchInlineSnapshot (
268
+ `"<p><a href=\\"#/url\\" target=\\"_blank\\">alt text</a></p>"`
269
+ ) ;
270
+ } ) ;
271
+
264
272
test ( 'class' , async function ( ) {
265
273
const output = window . marked (
266
274
"[alt text](http://url ':class=someCssClass')"
You can’t perform that action at this time.
0 commit comments