mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 23:06:49 +01:00
Fix Markdown style paths possibly being handled incorrectly on windows Fixes #3613
This commit is contained in:
@@ -59,22 +59,18 @@ export class MDDocumentContentProvider implements vscode.TextDocumentContentProv
|
||||
return vscode.Uri.file(this.context.asAbsolutePath(path.join('media', mediaFile))).toString();
|
||||
}
|
||||
|
||||
private isAbsolute(p: string): boolean {
|
||||
return path.normalize(p + '/') === path.normalize(path.resolve(p) + '/');
|
||||
}
|
||||
|
||||
private fixHref(resource: vscode.Uri, href: string): string {
|
||||
if (!href) {
|
||||
return href;
|
||||
}
|
||||
|
||||
// Use href if it is already an URL
|
||||
if (vscode.Uri.parse(href).scheme) {
|
||||
if (['file', 'http', 'https'].indexOf(vscode.Uri.parse(href).scheme) >= 0) {
|
||||
return href;
|
||||
}
|
||||
|
||||
// Use href as file URI if it is absolute
|
||||
if (this.isAbsolute(href)) {
|
||||
if (path.isAbsolute(href)) {
|
||||
return vscode.Uri.file(href).toString();
|
||||
}
|
||||
|
||||
@@ -89,7 +85,7 @@ export class MDDocumentContentProvider implements vscode.TextDocumentContentProv
|
||||
}
|
||||
|
||||
private computeCustomStyleSheetIncludes(uri: vscode.Uri): string {
|
||||
const styles = vscode.workspace.getConfiguration('markdown')['styles'];
|
||||
const styles: string[] = vscode.workspace.getConfiguration('markdown')['styles'];
|
||||
if (styles && Array.isArray(styles) && styles.length > 0) {
|
||||
return styles.map((style) => {
|
||||
return `<link rel="stylesheet" href="${this.fixHref(uri, style)}" type="text/css" media="screen">`;
|
||||
|
||||
Reference in New Issue
Block a user