Skip to content

Commit 82e9a14

Browse files
Fix: do not encode external links (microsoft#186778)
* bug fixes * added label to copyPaste.ts * added localized label to copyPasteLinks file * quick fix for pasting highlight bug * concise if-statement * external urls are not automatically encoded
1 parent e145525 commit 82e9a14

File tree

1 file changed

+11
-2
lines changed
  • extensions/markdown-language-features/src/languageFeatures/copyFiles

1 file changed

+11
-2
lines changed

extensions/markdown-language-features/src/languageFeatures/copyFiles/shared.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ enum MediaKind {
1717
Audio,
1818
}
1919

20+
const externalUriSchemes = [
21+
'http',
22+
'https',
23+
];
24+
2025
export const mediaFileExtensions = new Map<string, MediaKind>([
2126
// Images
2227
['bmp', MediaKind.Image],
@@ -161,7 +166,12 @@ export function createUriListSnippet(
161166
insertedLinkCount++;
162167
snippet.appendText('[');
163168
snippet.appendPlaceholder(escapeBrackets(title) || 'Title', placeholderValue);
164-
snippet.appendText(`](${escapeMarkdownLinkPath(mdPath)})`);
169+
if (externalUriSchemes.includes(uri.scheme)) {
170+
const uriString = uri.toString(true);
171+
snippet.appendText(`](${uriString})`);
172+
} else {
173+
snippet.appendText(`](${escapeMarkdownLinkPath(mdPath)})`);
174+
}
165175
}
166176
}
167177

@@ -292,7 +302,6 @@ function escapeMarkdownLinkPath(mdPath: string): string {
292302

293303
function escapeBrackets(value: string): string {
294304
value = value.replace(/[\[\]]/g, '\\$&');
295-
// value = value.replace(/\r\n\r\n/g, '\n\n');
296305
return value;
297306
}
298307

0 commit comments

Comments
 (0)