mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
@@ -231,6 +231,13 @@ export class MarkdownEngine {
|
|||||||
return normalizeLink(vscode.Uri.parse(link).with({ scheme: vscode.env.uriScheme }).toString());
|
return normalizeLink(vscode.Uri.parse(link).with({ scheme: vscode.env.uriScheme }).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support file:// links
|
||||||
|
if (isOfScheme(Schemes.file, link)) {
|
||||||
|
// Ensure link is relative by prepending `/` so that it uses the <base> element URI
|
||||||
|
// when resolving the absolute URL
|
||||||
|
return normalizeLink('/' + link.replace(/^file:/, 'file'));
|
||||||
|
}
|
||||||
|
|
||||||
// If original link doesn't look like a url with a scheme, assume it must be a link to a file in workspace
|
// If original link doesn't look like a url with a scheme, assume it must be a link to a file in workspace
|
||||||
if (!/^[a-z\-]+:/i.test(link)) {
|
if (!/^[a-z\-]+:/i.test(link)) {
|
||||||
// Use a fake scheme for parsing
|
// Use a fake scheme for parsing
|
||||||
@@ -241,12 +248,14 @@ export class MarkdownEngine {
|
|||||||
if (uri.path[0] === '/') {
|
if (uri.path[0] === '/') {
|
||||||
const root = vscode.workspace.getWorkspaceFolder(this.currentDocument!);
|
const root = vscode.workspace.getWorkspaceFolder(this.currentDocument!);
|
||||||
if (root) {
|
if (root) {
|
||||||
const fileUri = vscode.Uri.joinPath(root.uri, uri.fsPath);
|
const fileUri = vscode.Uri.joinPath(root.uri, uri.fsPath).with({
|
||||||
uri = fileUri.with({
|
|
||||||
scheme: uri.scheme,
|
|
||||||
fragment: uri.fragment,
|
fragment: uri.fragment,
|
||||||
query: uri.query,
|
query: uri.query,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Ensure fileUri is relative by prepending `/` so that it uses the <base> element URI
|
||||||
|
// when resolving the absolute URL
|
||||||
|
uri = vscode.Uri.parse('markdown-link:' + '/' + fileUri.toString(true).replace(/^\S+?:/, fileUri.scheme));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,9 +278,7 @@ export class MarkdownEngine {
|
|||||||
private addLinkValidator(md: any): void {
|
private addLinkValidator(md: any): void {
|
||||||
const validateLink = md.validateLink;
|
const validateLink = md.validateLink;
|
||||||
md.validateLink = (link: string) => {
|
md.validateLink = (link: string) => {
|
||||||
// support file:// links
|
|
||||||
return validateLink(link)
|
return validateLink(link)
|
||||||
|| isOfScheme(Schemes.file, link)
|
|
||||||
|| isOfScheme(Schemes.vscode, link)
|
|| isOfScheme(Schemes.vscode, link)
|
||||||
|| isOfScheme(Schemes['vscode-insiders'], link)
|
|| isOfScheme(Schemes['vscode-insiders'], link)
|
||||||
|| /^data:image\/.*?;/.test(link);
|
|| /^data:image\/.*?;/.test(link);
|
||||||
|
|||||||
Reference in New Issue
Block a user