Minor bug fix in service worker
parent
481387d235
commit
5904326f0c
|
@ -1,4 +1,4 @@
|
|||
import { base64Decode, base64Encode } from "../lib/crypto.ts";
|
||||
import { base64Decode, base64Encode } from "$lib/crypto.ts";
|
||||
|
||||
export type ProxyFetchRequest = {
|
||||
method?: string;
|
||||
|
|
|
@ -71,8 +71,12 @@ self.addEventListener("fetch", (event: any) => {
|
|||
event.respondWith(
|
||||
(async () => {
|
||||
const request = event.request;
|
||||
const requestUrl = new URL(request.url);
|
||||
|
||||
// console.log("Getting request", request, [...request.headers.entries()]);
|
||||
// Are we fetching a URL from the same origin as the app? If not, we don't handle it and pass it on
|
||||
if (location.host !== requestUrl.host) {
|
||||
return fetch(request);
|
||||
}
|
||||
|
||||
// Any request with the X-Sync-Mode header originates from the sync engine: pass it on to the server
|
||||
if (request.headers.has("x-sync-mode")) {
|
||||
|
@ -91,14 +95,8 @@ self.addEventListener("fetch", (event: any) => {
|
|||
return fetch(request);
|
||||
}
|
||||
|
||||
const requestUrl = new URL(request.url);
|
||||
const pathname = requestUrl.pathname;
|
||||
|
||||
// Are we fetching a URL from the same origin as the app? If not, we don't handle it and pass it on
|
||||
if (location.host !== requestUrl.host) {
|
||||
return fetch(request);
|
||||
}
|
||||
|
||||
if (pathname === "/.auth" || pathname === "/index.json") {
|
||||
return fetch(request);
|
||||
} else if (/\/.+\.[a-zA-Z]+$/.test(pathname)) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import type { SysCallMapping } from "../../lib/plugos/system.ts";
|
||||
import type { SysCallMapping } from "$lib/plugos/system.ts";
|
||||
import {
|
||||
performLocalFetch,
|
||||
ProxyFetchRequest,
|
||||
ProxyFetchResponse,
|
||||
} from "$common/proxy_fetch.ts";
|
||||
import type { Client } from "../client.ts";
|
||||
import { base64Decode, base64Encode } from "../../lib/crypto.ts";
|
||||
import { base64Decode, base64Encode } from "$lib/crypto.ts";
|
||||
|
||||
export function sandboxFetchSyscalls(
|
||||
client: Client,
|
||||
|
|
Loading…
Reference in New Issue