@@ -189,11 +189,11 @@ export function appendToLinkSnippet(
189189 title : string ,
190190 link : string ,
191191 placeholderValue : number ,
192- isExternalLink : boolean ,
192+ _isExternalLink : boolean ,
193193) : void {
194194 snippet . appendText ( '[' ) ;
195195 snippet . appendPlaceholder ( escapeBrackets ( title ) || 'Title' , placeholderValue ) ;
196- snippet . appendText ( `](${ escapeMarkdownLinkPath ( link , isExternalLink ) } )` ) ;
196+ snippet . appendText ( `](${ escapeMarkdownLinkPath ( link ) } )` ) ;
197197}
198198
199199export function createUriListSnippet (
@@ -238,17 +238,15 @@ export function createUriListSnippet(
238238 snippet . appendPlaceholder ( escapeBrackets ( title ) || 'Title' , placeholderValue ) ;
239239 snippet . appendText ( '"></audio>' ) ;
240240 } else if ( insertAsMedia ) {
241- if ( insertAsMedia ) {
242- insertedImageCount ++ ;
243- if ( pasteAsMarkdownLink ) {
244- snippet . appendText ( ' } )` ) ;
249- } else {
250- snippet . appendText ( escapeMarkdownLinkPath ( mdPath , isExternalLink ) ) ;
251- }
241+ insertedImageCount ++ ;
242+ if ( pasteAsMarkdownLink ) {
243+ snippet . appendText ( ' } )` ) ;
248+ } else {
249+ snippet . appendText ( escapeMarkdownLinkPath ( mdPath ) ) ;
252250 }
253251 } else {
254252 insertedLinkCount ++ ;
@@ -371,20 +369,20 @@ function escapeHtmlAttribute(attr: string): string {
371369 return encodeURI ( attr ) . replaceAll ( '"' , '"' ) ;
372370}
373371
374- function escapeMarkdownLinkPath ( mdPath : string , isExternalLink : boolean ) : string {
372+ function escapeMarkdownLinkPath ( mdPath : string ) : string {
375373 if ( needsBracketLink ( mdPath ) ) {
376374 return '<' + mdPath . replaceAll ( '<' , '\\<' ) . replaceAll ( '>' , '\\>' ) + '>' ;
377375 }
378376
379- return isExternalLink ? mdPath : encodeURI ( mdPath ) ;
377+ return mdPath ;
380378}
381379
382380function escapeBrackets ( value : string ) : string {
383381 value = value . replace ( / [ \[ \] ] / g, '\\$&' ) ; // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.
384382 return value ;
385383}
386384
387- function needsBracketLink ( mdPath : string ) {
385+ function needsBracketLink ( mdPath : string ) : boolean {
388386 // Links with whitespace or control characters must be enclosed in brackets
389387 if ( mdPath . startsWith ( '<' ) || / \s | [ \u007F \u0000 - \u001f ] / . test ( mdPath ) ) {
390388 return true ;
0 commit comments