From 9b9905f640202d538102d59eccef1f2127a74838 Mon Sep 17 00:00:00 2001 From: velzie Date: Tue, 30 Jul 2024 08:19:03 -0400 Subject: [PATCH] fix url rewrites for blob worker --- src/shared/rewriters/url.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/shared/rewriters/url.ts b/src/shared/rewriters/url.ts index 338a0a6..3daee85 100644 --- a/src/shared/rewriters/url.ts +++ b/src/shared/rewriters/url.ts @@ -17,13 +17,16 @@ export function encodeUrl(url: string | URL, origin?: URL) { } if (!origin) { - origin = new URL( - self.$scramjet.config.codec.decode( - location.href.slice( - (location.origin + self.$scramjet.config.prefix).length + if (location.pathname.startsWith(self.$scramjet.config.prefix + "worker")) { + origin = new URL(new URL(location.href).searchParams.get("origin")); + } else + origin = new URL( + self.$scramjet.config.codec.decode( + location.href.slice( + (location.origin + self.$scramjet.config.prefix).length + ) ) - ) - ); + ); } // is this the correct behavior?