Enable paste url for file uris (#203270)

Fixes #203180
This commit is contained in:
Matt Bierner 2024-01-23 17:08:58 -08:00 committed by GitHub
parent c77b63e865
commit 9c95828898
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 8 deletions

View file

@ -7,7 +7,8 @@ import * as vscode from 'vscode';
import { IMdParser } from '../../markdownEngine';
import { ITextDocument } from '../../types/textDocument';
import { Mime } from '../../util/mimes';
import { createInsertUriListEdit, externalUriSchemes } from './shared';
import { createInsertUriListEdit } from './shared';
import { Schemes } from '../../util/schemes';
export enum PasteUrlAsMarkdownLink {
Always = 'always',
@ -170,6 +171,14 @@ async function shouldSmartPasteForSelection(
return true;
}
const externalUriSchemes: ReadonlySet<string> = new Set([
Schemes.http,
Schemes.https,
Schemes.mailto,
Schemes.file,
]);
export function findValidUriInText(text: string): string | undefined {
const trimmedUrlList = text.trim();
@ -186,7 +195,7 @@ export function findValidUriInText(text: string): string | undefined {
return;
}
if (!externalUriSchemes.includes(uri.scheme.toLowerCase()) || uri.authority.length <= 1) {
if (!externalUriSchemes.has(uri.scheme.toLowerCase()) || uri.authority.length <= 1) {
return;
}

View file

@ -19,12 +19,6 @@ enum MediaKind {
Audio,
}
export const externalUriSchemes = [
'http',
'https',
'mailto',
];
export const mediaFileExtensions = new Map<string, MediaKind>([
// Images
['bmp', MediaKind.Image],

View file

@ -4,6 +4,8 @@
*--------------------------------------------------------------------------------------------*/
export const Schemes = Object.freeze({
http: 'http',
https: 'https',
file: 'file',
untitled: 'untitled',
mailto: 'mailto',