Align switch case style in service worker (#163364)

This commit is contained in:
Matt Bierner 2022-10-11 16:06:58 -07:00 committed by GitHub
parent cc8feda380
commit 0abb1e99c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -122,8 +122,7 @@ const methodNotAllowed = () =>
sw.addEventListener('message', async (event) => {
switch (event.data.channel) {
case 'version':
{
case 'version': {
const source = /** @type {Client} */ (event.source);
sw.clients.get(source.id).then(client => {
if (client) {
@ -135,8 +134,7 @@ sw.addEventListener('message', async (event) => {
});
return;
}
case 'did-load-resource':
{
case 'did-load-resource': {
/** @type {ResourceResponse} */
const response = event.data.data;
if (!resourceRequestStore.resolve(response.id, response)) {
@ -144,18 +142,18 @@ sw.addEventListener('message', async (event) => {
}
return;
}
case 'did-load-localhost':
{
case 'did-load-localhost': {
const data = event.data.data;
if (!localhostRequestStore.resolve(data.id, data.location)) {
console.log('Could not resolve unknown localhost', data.origin);
}
return;
}
default:
default: {
console.log('Unknown message');
return;
}
}
});
sw.addEventListener('fetch', (event) => {
@ -174,10 +172,11 @@ sw.addEventListener('fetch', (event) => {
query: requestUrl.search.replace(/^\?/, ''),
}));
}
default:
default: {
return event.respondWith(methodNotAllowed());
}
}
}
// If we're making a request against the remote authority, we want to go
// through VS Code itself so that we are authenticated properly. If the
@ -186,18 +185,19 @@ sw.addEventListener('fetch', (event) => {
if (requestUrl.origin !== sw.origin && requestUrl.host === remoteAuthority) {
switch (event.request.method) {
case 'GET':
case 'HEAD':
case 'HEAD': {
return event.respondWith(processResourceRequest(event, {
path: requestUrl.pathname,
scheme: requestUrl.protocol.slice(0, requestUrl.protocol.length - 1),
authority: requestUrl.host,
query: requestUrl.search.replace(/^\?/, ''),
}));
default:
}
default: {
return event.respondWith(methodNotAllowed());
}
}
}
// See if it's a localhost request
if (requestUrl.origin !== sw.origin && requestUrl.host.match(/^(localhost|127.0.0.1|0.0.0.0):(\d+)$/)) {