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 = ({
2828 }
2929
3030 href = router . toURL ( href , null , router . getCurrentPath ( ) ) ;
31+
32+ if ( config . target ) {
33+ href . indexOf ( 'mailto:' ) !== 0 && attrs . push ( `target="${ linkTarget } "` ) ;
34+ }
3135 } else {
3236 if ( ! isAbsolutePath ( href ) && href . slice ( 0 , 2 ) === './' ) {
3337 href =
Original file line number Diff line number Diff line change @@ -253,14 +253,22 @@ describe('render', function () {
253253 ) ;
254254 } ) ;
255255
256- test ( 'target' , async function ( ) {
256+ test ( 'target for absolute path ' , async function ( ) {
257257 const output = window . marked ( "[alt text](http://url ':target=_self')" ) ;
258258
259259 expect ( output ) . toMatchInlineSnapshot (
260260 `"<p><a href=\\"http://url\\" target=\\"_self\\" >alt text</a></p>"`
261261 ) ;
262262 } ) ;
263263
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+
264272 test ( 'class' , async function ( ) {
265273 const output = window . marked (
266274 "[alt text](http://url ':class=someCssClass')"
You can’t perform that action at this time.
0 commit comments