mirror of
https://github.com/Microsoft/vscode
synced 2024-09-12 21:24:38 +00:00
Align switch case style in service worker (#163364)
This commit is contained in:
parent
cc8feda380
commit
0abb1e99c2
|
@ -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+)$/)) {
|
||||
|
|
Loading…
Reference in a new issue