From ca79f507d7df0d610974fee2ac94c8251f87af97 Mon Sep 17 00:00:00 2001 From: Percs <83934299+Percslol@users.noreply.github.com> Date: Thu, 17 Oct 2024 01:30:07 -0500 Subject: [PATCH] fix: proxy postmessage properly --- src/client/shared/postmessage.ts | 7 +++---- src/client/shared/worker.ts | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/client/shared/postmessage.ts b/src/client/shared/postmessage.ts index 33b1054..b436b0c 100644 --- a/src/client/shared/postmessage.ts +++ b/src/client/shared/postmessage.ts @@ -55,11 +55,10 @@ export default function (client: ScramjetClient) { }; // * origin because obviously - ctx.args[1] = "*"; + if (typeof ctx.args[1] === "string") ctx.args[1] = "*"; + if (typeof ctx.args[1] === "object") ctx.args[1].targetOrigin = "*"; - ctx.return( - wrappedPostMessage.call(ctx.fn, ctx.args[0], ctx.args[1], ctx.args[2]) - ); + ctx.return(wrappedPostMessage.call(ctx.fn, ...ctx.args)); }, }); diff --git a/src/client/shared/worker.ts b/src/client/shared/worker.ts index 30c24af..d00bd58 100644 --- a/src/client/shared/worker.ts +++ b/src/client/shared/worker.ts @@ -61,7 +61,7 @@ export default function (client: ScramjetClient, self: typeof globalThis) { args[0] += "&type=module"; } - if (args[1].name === "name") { + if (args[1].name) { args[1].name = `${client.url.origin}@${args[1].name}`; } }