mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 23:10:02 -04:00
add license and client apis
This commit is contained in:
parent
ecff2aca52
commit
aac959936c
19 changed files with 1004 additions and 89 deletions
33
src/client/fetch.ts
Normal file
33
src/client/fetch.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
// ts throws an error if you dont do window.fetch
|
||||
|
||||
window.fetch = new Proxy(window.fetch, {
|
||||
apply(target, thisArg, argArray) {
|
||||
argArray[0] = self.__scramjet$bundle.rewriters.url.encodeUrl(argArray[0]);
|
||||
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
},
|
||||
});
|
||||
|
||||
Headers = new Proxy(Headers, {
|
||||
construct(target, argArray, newTarget) {
|
||||
argArray[0] = self.__scramjet$bundle.rewriters.rewriteHeaders(argArray[0]);
|
||||
|
||||
return Reflect.construct(target, argArray, newTarget);
|
||||
},
|
||||
})
|
||||
|
||||
Request = new Proxy(Request, {
|
||||
construct(target, argArray, newTarget) {
|
||||
if (typeof argArray[0] === "string") argArray[0] = self.__scramjet$bundle.rewriters.url.encodeUrl(argArray[0]);
|
||||
|
||||
return Reflect.construct(target, argArray, newTarget);
|
||||
},
|
||||
});
|
||||
|
||||
Response.redirect = new Proxy(Response.redirect, {
|
||||
apply(target, thisArg, argArray) {
|
||||
argArray[0] = self.__scramjet$bundle.rewriters.url.encodeUrl(argArray[0]);
|
||||
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue