提交 38aadec9 编写于 作者: J Johannes Rieken

use structured data as query so that requests can be retriggered if needed, #75061

上级 691914ea
......@@ -1199,7 +1199,7 @@ export function asDomUri(uri: URI): URI {
if (Schemas.vscodeRemote === uri.scheme) {
// rewrite vscode-remote-uris to uris of the window location
// so that they can be intercepted by the service worker
return _location.with({ path: '/vscode-resources/fetch', query: uri.toString() });
return _location.with({ path: '/vscode-resources/fetch', query: JSON.stringify({ u: uri.toJSON(), i: 1 }) });
}
return uri;
}
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vs/base/common/uri';
import { URI, UriComponents } from 'vs/base/common/uri';
import { generateUuid } from 'vs/base/common/uuid';
import { getMediaMime } from 'vs/base/common/mime';
......@@ -78,13 +78,13 @@ async function respondWithResource(event: FetchEvent, uri: URI): Promise<Respons
return new Promise<Response>(resolve => {
const token = generateUuid();
const resourceUri = URI.parse(uri.query);
const query: { u: UriComponents, i: number } = JSON.parse(uri.query);
_pendingFetch.set(token, async (data: ArrayBuffer, isExtensionResource: boolean) => {
const res = new Response(data, {
status: 200,
headers: { 'Content-Type': getMediaMime(resourceUri.path) || 'text/plain' }
headers: { 'Content-Type': getMediaMime(query.u.path) || 'text/plain' }
});
if (isExtensionResource) {
......@@ -97,7 +97,7 @@ async function respondWithResource(event: FetchEvent, uri: URI): Promise<Respons
});
self.clients.get(event.clientId).then(client => {
client.postMessage({ uri: resourceUri, token });
client.postMessage({ uri: query.u, token });
});
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册