Merge from vscode 0fde6619172c9f04c41f2e816479e432cc974b8b (#5199)

This commit is contained in:
Anthony Dresser
2019-04-24 22:26:02 -07:00
committed by GitHub
parent d63f07d29a
commit 34457880c7
86 changed files with 1254 additions and 702 deletions

View File

@@ -34,24 +34,26 @@ export function registerFileProtocol(
getRoots: () => ReadonlyArray<URI>
) {
contents.session.protocol.registerBufferProtocol(protocol, (request, callback: any) => {
if (extensionLocation && extensionLocation.scheme === REMOTE_HOST_SCHEME) {
const requestUri = URI.parse(request.url);
const redirectedUri = URI.from({
scheme: REMOTE_HOST_SCHEME,
authority: extensionLocation.authority,
path: '/vscode-resource',
query: JSON.stringify({
requestResourcePath: requestUri.path
})
});
resolveContent(textFileService, redirectedUri, getMimeType(requestUri), callback);
return;
}
const requestPath = URI.parse(request.url).path;
const normalizedPath = URI.file(requestPath);
for (const root of getRoots()) {
if (startsWith(normalizedPath.fsPath, root.fsPath + sep)) {
if (!startsWith(normalizedPath.fsPath, root.fsPath + sep)) {
continue;
}
if (extensionLocation && extensionLocation.scheme === REMOTE_HOST_SCHEME) {
const requestUri = URI.parse(request.url);
const redirectedUri = URI.from({
scheme: REMOTE_HOST_SCHEME,
authority: extensionLocation.authority,
path: '/vscode-resource',
query: JSON.stringify({
requestResourcePath: requestUri.path
})
});
resolveContent(textFileService, redirectedUri, getMimeType(requestUri), callback);
return;
} else {
resolveContent(textFileService, normalizedPath, getMimeType(normalizedPath), callback);
return;
}