mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 01:25:38 -05:00
Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)
* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 * disable strict null check
This commit is contained in:
33
extensions/markdown-language-features/src/util/resources.ts
Normal file
33
extensions/markdown-language-features/src/util/resources.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export interface WebviewResourceProvider {
|
||||
toWebviewResource(resource: vscode.Uri): vscode.Uri;
|
||||
|
||||
readonly cspSource: string;
|
||||
}
|
||||
|
||||
export function normalizeResource(
|
||||
base: vscode.Uri,
|
||||
resource: vscode.Uri
|
||||
): vscode.Uri {
|
||||
// If we have a windows path and are loading a workspace with an authority,
|
||||
// make sure we use a unc path with an explicit localhost authority.
|
||||
//
|
||||
// Otherwise, the `<base>` rule will insert the authority into the resolved resource
|
||||
// URI incorrectly.
|
||||
if (base.authority && !resource.authority) {
|
||||
const driveMatch = resource.path.match(/^\/(\w):\//);
|
||||
if (driveMatch) {
|
||||
return vscode.Uri.file(`\\\\localhost\\${driveMatch[1]}$\\${resource.fsPath.replace(/^\w:\\/, '')}`).with({
|
||||
fragment: resource.fragment,
|
||||
query: resource.query
|
||||
});
|
||||
}
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
Reference in New Issue
Block a user