Skip to content

Commit

Permalink
Fix markdown.styled regression caused by Uri.parse changes
Browse files Browse the repository at this point in the history
Fixes #71802

Uri.parse now defaults to a `file` scheme, which broke this code
  • Loading branch information
mjbvz committed Apr 5, 2019
1 parent 97f93d2 commit f44e51e
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,19 @@ export class MarkdownContentProvider {
return href;
}

// Use href if it is already an URL
const hrefUri = vscode.Uri.parse(href);
if (['http', 'https'].indexOf(hrefUri.scheme) >= 0) {
return hrefUri.toString(true);
if (href.startsWith('http:') || href.startsWith('https:') || href.startsWith('file:')) {
return href;
}

// Use href as file URI if it is absolute
if (path.isAbsolute(href) || hrefUri.scheme === 'file') {
// Assume it must be a local file
if (path.isAbsolute(href)) {
return vscode.Uri.file(href)
.with({ scheme: 'vscode-resource' })
.toString();
}

// Use a workspace relative path if there is a workspace
let root = vscode.workspace.getWorkspaceFolder(resource);
const root = vscode.workspace.getWorkspaceFolder(resource);
if (root) {
return vscode.Uri.file(path.join(root.uri.fsPath, href))
.with({ scheme: 'vscode-resource' })
Expand Down

0 comments on commit f44e51e

Please sign in to comment.