提交 f93afc56 编写于 作者: M Matt Bierner

Fix Markdown style paths possibly being handled incorrectly on windows Fixes #3613

上级 7fbf9820
......@@ -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">`;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册