mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +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:
parent
e145525917
commit
82e9a14903
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue