This commit is contained in:
velzie 2024-07-30 07:22:20 -04:00
commit 2ed32461d9
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
10 changed files with 521 additions and 538 deletions

View file

@ -1,11 +1,19 @@
// ts throws an error if you dont do window.fetch
import { ScramjetClient } from "../../client";
import { encodeUrl, rewriteHeaders } from "../../shared";
export default function (client: ScramjetClient, self: typeof globalThis) {
client.Proxy("fetch", {
apply(ctx) {
ctx.args[0] = encodeUrl(ctx.args[0]);
if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) {
ctx.args[0].toString();
ctx.args[0] = encodeUrl(ctx.args[0].toString());
} else if (ctx.args[0] instanceof Request && ctx.args[0].url) {
Object.defineProperty(ctx.args[0], "url", {
value: encodeUrl(ctx.args[0].url),
});
}
},
});