File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,12 @@ export const linkCompiler = ({
2828 }
2929
3030 href = router . toURL ( href , null , router . getCurrentPath ( ) ) ;
31+
32+ if ( config . target ) {
33+ attrs . push (
34+ href . indexOf ( 'mailto:' ) === 0 ? '' : `target="${ linkTarget } "`
35+ ) ;
36+ }
3137 } else {
3238 if ( ! isAbsolutePath ( href ) && href . slice ( 0 , 2 ) === './' ) {
3339 href =
Original file line number Diff line number Diff line change @@ -238,14 +238,23 @@ describe('render', function () {
238238 ) ;
239239 } ) ;
240240
241- test ( 'target' , async function ( ) {
241+ test ( 'target for absolute path ' , async function ( ) {
242242 const output = window . marked ( "[alt text](http://url ':target=_self')" ) ;
243243
244244 expect ( output ) . toMatchInlineSnapshot (
245245 `"<p><a href=\\"http://url\\" target=\\"_self\\" >alt text</a></p>"`
246246 ) ;
247247 } ) ;
248248
249+ test ( 'target for relative path' , async function ( ) {
250+ const output = window . marked ( "[alt text](/url ':target=_blank')" ) ;
251+ console . log ( output ) ;
252+
253+ expect ( output ) . toMatchInlineSnapshot (
254+ `"<p><a href=\\"#/url\\" target=\\"_blank\\">alt text</a></p>"`
255+ ) ;
256+ } ) ;
257+
249258 test ( 'class' , async function ( ) {
250259 const output = window . marked (
251260 "[alt text](http://url ':class=someCssClass')"
You can’t perform that action at this time.
0 commit comments