mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 15:00:01 -04:00
Merge branch 'main' of https://github.com/MercuryWorkshop/scramjet
This commit is contained in:
commit
baccc82ab7
4 changed files with 19 additions and 2 deletions
35
src/client/requests/fetch.ts
Normal file
35
src/client/requests/fetch.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
// ts throws an error if you dont do window.fetch
|
||||
|
||||
import { encodeUrl, rewriteHeaders } from "../bundle";
|
||||
|
||||
window.fetch = new Proxy(window.fetch, {
|
||||
apply(target, thisArg, argArray) {
|
||||
argArray[0] = encodeUrl(argArray[0]);
|
||||
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
},
|
||||
});
|
||||
|
||||
Headers = new Proxy(Headers, {
|
||||
construct(target, argArray, newTarget) {
|
||||
argArray[0] = rewriteHeaders(argArray[0]);
|
||||
|
||||
return Reflect.construct(target, argArray, newTarget);
|
||||
},
|
||||
})
|
||||
|
||||
Request = new Proxy(Request, {
|
||||
construct(target, argArray, newTarget) {
|
||||
if (typeof argArray[0] === "string") argArray[0] = encodeUrl(argArray[0]);
|
||||
|
||||
return Reflect.construct(target, argArray, newTarget);
|
||||
},
|
||||
});
|
||||
|
||||
Response.redirect = new Proxy(Response.redirect, {
|
||||
apply(target, thisArg, argArray) {
|
||||
argArray[0] = encodeUrl(argArray[0]);
|
||||
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue