mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-27 13:40:25 +00:00
Fix: do not encode external links (#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
This commit is contained in:
@@ -17,6 +17,11 @@ enum MediaKind {
|
||||
Audio,
|
||||
}
|
||||
|
||||
const externalUriSchemes = [
|
||||
'http',
|
||||
'https',
|
||||
];
|
||||
|
||||
export const mediaFileExtensions = new Map<string, MediaKind>([
|
||||
// Images
|
||||
['bmp', MediaKind.Image],
|
||||
@@ -161,7 +166,12 @@ export function createUriListSnippet(
|
||||
insertedLinkCount++;
|
||||
snippet.appendText('[');
|
||||
snippet.appendPlaceholder(escapeBrackets(title) || 'Title', placeholderValue);
|
||||
snippet.appendText(`](${escapeMarkdownLinkPath(mdPath)})`);
|
||||
if (externalUriSchemes.includes(uri.scheme)) {
|
||||
const uriString = uri.toString(true);
|
||||
snippet.appendText(`](${uriString})`);
|
||||
} else {
|
||||
snippet.appendText(`](${escapeMarkdownLinkPath(mdPath)})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +302,6 @@ function escapeMarkdownLinkPath(mdPath: string): string {
|
||||
|
||||
function escapeBrackets(value: string): string {
|
||||
value = value.replace(/[\[\]]/g, '\\$&');
|
||||
// value = value.replace(/\r\n\r\n/g, '\n\n');
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user