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:
Meghan Kulkarni 2023-06-30 13:19:03 -07:00 committed by GitHub
parent e145525917
commit 82e9a14903
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}