@@ -214,9 +214,9 @@ export function appendToLinkSnippet(
214
214
if ( pasteAsMarkdownLink ) {
215
215
snippet . appendText ( '[' ) ;
216
216
snippet . appendPlaceholder ( escapeBrackets ( title ) || 'Title' , placeholderValue ) ;
217
- snippet . appendText ( isExternalLink ? `](${ uriString } )` : `]( ${ escapeMarkdownLinkPath ( mdPath ) } )`) ;
217
+ snippet . appendText ( `](${ escapeMarkdownLinkPath ( isExternalLink ? uriString : mdPath , isExternalLink ) } )` ) ;
218
218
} else {
219
- snippet . appendText ( isExternalLink ? uriString : escapeMarkdownLinkPath ( mdPath ) ) ;
219
+ snippet . appendText ( ( escapeMarkdownLinkPath ( isExternalLink ? uriString : mdPath , isExternalLink ) ) ) ;
220
220
}
221
221
return snippet ;
222
222
}
@@ -268,9 +268,9 @@ export function createUriListSnippet(
268
268
const placeholderText = escapeBrackets ( title ) || options ?. placeholderText || 'Alt text' ;
269
269
const placeholderIndex = typeof options ?. placeholderStartIndex !== 'undefined' ? options ?. placeholderStartIndex + i : ( placeholderValue === 0 ? undefined : placeholderValue ) ;
270
270
snippet . appendPlaceholder ( placeholderText , placeholderIndex ) ;
271
- snippet . appendText ( `](${ escapeMarkdownLinkPath ( mdPath ) } )` ) ;
271
+ snippet . appendText ( `](${ escapeMarkdownLinkPath ( mdPath , isExternalLink ) } )` ) ;
272
272
} else {
273
- snippet . appendText ( escapeMarkdownLinkPath ( mdPath ) ) ;
273
+ snippet . appendText ( escapeMarkdownLinkPath ( mdPath , isExternalLink ) ) ;
274
274
}
275
275
}
276
276
} else {
@@ -397,12 +397,12 @@ function escapeHtmlAttribute(attr: string): string {
397
397
return encodeURI ( attr ) . replaceAll ( '"' , '"' ) ;
398
398
}
399
399
400
- function escapeMarkdownLinkPath ( mdPath : string ) : string {
400
+ function escapeMarkdownLinkPath ( mdPath : string , isExternalLink : boolean ) : string {
401
401
if ( needsBracketLink ( mdPath ) ) {
402
402
return '<' + mdPath . replaceAll ( '<' , '\\<' ) . replaceAll ( '>' , '\\>' ) + '>' ;
403
403
}
404
404
405
- return encodeURI ( mdPath ) ;
405
+ return isExternalLink ? mdPath : encodeURI ( mdPath ) ;
406
406
}
407
407
408
408
function escapeBrackets ( value : string ) : string {
0 commit comments