Skip to content

Commit

Permalink
Adopt 'asWebviewUri' API, #319
Browse files Browse the repository at this point in the history
  • Loading branch information
qjebbs committed May 21, 2020
1 parent 66a00e7 commit 1542b68
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "2.13.11",
"publisher": "jebbs",
"engines": {
"vscode": "^1.23.0"
"vscode": "^1.39.0"
},
"license": "SEE LICENSE IN LICENSE.txt",
"bugs": {
Expand Down
8 changes: 4 additions & 4 deletions src/ui/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ export class UI extends vscode.Disposable {
let linkReg = /(src|href)\s*=\s*([`"'])(.+?)\2/ig;
let base: string = this._resourceRoot;
result = result.replace(linkReg, (match, ...subs) => {
let uri = subs[2] as string;
if (!path.isAbsolute(uri)) uri = path.join(base, uri);
if (!fs.existsSync(uri)) return match;
uri = vscode.Uri.file(uri).with({ scheme: 'vscode-resource' }).toString();
let file = subs[2] as string;
if (!path.isAbsolute(file)) file = path.join(base, file);
if (!fs.existsSync(file)) return match;
let uri = this._panel.webview.asWebviewUri(vscode.Uri.file(file));
return `${subs[0]}=${subs[1]}${uri}${subs[1]}`;
});
return result;
Expand Down

0 comments on commit 1542b68

Please sign in to comment.