Adding toWebviewResource api

For #76489
This commit is contained in:
Matt Bierner
2019-07-03 19:14:19 -07:00
parent 3492642650
commit a558a9504a
20 changed files with 168 additions and 114 deletions

View File

@@ -0,0 +1,24 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vs/base/common/uri';
import * as vscode from 'vscode';
export interface WebviewInitData {
readonly webviewResourceRoot: string;
readonly webviewCspRule: string;
}
export function toWebviewResource(
initData: WebviewInitData,
resource: vscode.Uri
): vscode.Uri {
const rootUri = URI.parse(initData.webviewResourceRoot);
return rootUri.with({
path: rootUri.path + resource.path,
query: resource.query,
fragment: resource.fragment,
});
}