Skip to content

Commit

Permalink
Don't use clone as much
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Jun 20, 2019
1 parent 355b569 commit 02db631
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/vs/workbench/contrib/webview/browser/pre/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ const resourceRequestStore = new RequestStore();
*/
const localhostRequestStore = new RequestStore();

const notFoundResponse = new Response('Not Found', {
status: 404,
});
const notFound = () =>
new Response('Not Found', { status: 404, });

self.addEventListener('message', async (event) => {
switch (event.data.channel) {
Expand Down Expand Up @@ -176,15 +175,15 @@ async function processResourceRequest(event, requestUrl) {
const client = await self.clients.get(event.clientId);
if (!client) {
console.log('Could not find inner client for request');
return notFoundResponse.clone();
return notFound();
}

const webviewId = getWebviewIdForClient(client);
const resourcePath = requestUrl.pathname.replace(resourceRoot, '');

function resolveResourceEntry(entry) {
if (!entry) {
return notFoundResponse.clone();
return notFound();
}
return new Response(entry.body, {
status: 200,
Expand All @@ -195,7 +194,7 @@ async function processResourceRequest(event, requestUrl) {
const parentClient = await getOuterIframeClient(webviewId);
if (!parentClient) {
console.log('Could not find parent client for request');
return notFoundResponse.clone();
return notFound();
}

// Check if we've already resolved this request
Expand Down Expand Up @@ -243,7 +242,7 @@ async function processLocalhostRequest(event, requestUrl) {
const parentClient = await getOuterIframeClient(webviewId);
if (!parentClient) {
console.log('Could not find parent client for request');
return notFoundResponse.clone();
return notFound();
}

// Check if we've already resolved this request
Expand Down

0 comments on commit 02db631

Please sign in to comment.