Merge pull request #74332 from lmcarreiro/master

Fix #48403 broken UNC paths in markdown images
This commit is contained in:
Matt Bierner 2019-07-02 17:24:39 -07:00 committed by GitHub
commit abe0c0698e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,7 +5,7 @@
import { VSBuffer } from 'vs/base/common/buffer';
import { sep } from 'vs/base/common/path';
import { startsWith } from 'vs/base/common/strings';
import { startsWith, endsWith } from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri';
import { IFileService } from 'vs/platform/files/common/files';
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
@ -45,10 +45,11 @@ export async function loadLocalResource(
extensionLocation: URI | undefined,
getRoots: () => ReadonlyArray<URI>
): Promise<LocalResourceResponse> {
const requestPath = requestUri.path;
const requestPath = requestUri.authority ? `//${requestUri.authority}${requestUri.path}` : requestUri.path;
const normalizedPath = URI.file(requestPath);
for (const root of getRoots()) {
if (!startsWith(normalizedPath.fsPath, root.fsPath + sep)) {
const rootPath = root.fsPath + (endsWith(root.fsPath, sep) ? '' : sep);
if (!startsWith(normalizedPath.fsPath, rootPath)) {
continue;
}