Skip to content

Commit

Permalink
use structured data as query so that requests can be retriggered if n…
Browse files Browse the repository at this point in the history
…eeded, #75061
  • Loading branch information
jrieken committed Jul 11, 2019
1 parent 691914e commit 38aadec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/vs/base/browser/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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) {
Expand All @@ -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 });
});
});
}
Expand Down

0 comments on commit 38aadec

Please sign in to comment.