mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
support url base
This commit is contained in:
parent
a1ce4e33b3
commit
7a9c990b01
32 changed files with 213 additions and 158 deletions
|
@ -1,16 +1,17 @@
|
|||
import { decodeUrl, encodeUrl, rewriteHeaders } from "../../../shared";
|
||||
import { ScramjetClient } from "../../client";
|
||||
|
||||
export default function (client, self) {
|
||||
export default function (client: ScramjetClient, self: Self) {
|
||||
client.Proxy("XMLHttpRequest.prototype.open", {
|
||||
apply(ctx) {
|
||||
if (ctx.args[1]) ctx.args[1] = encodeUrl(ctx.args[1]);
|
||||
if (ctx.args[1]) ctx.args[1] = encodeUrl(ctx.args[1], client.meta);
|
||||
},
|
||||
});
|
||||
|
||||
client.Proxy("XMLHttpRequest.prototype.setRequestHeader", {
|
||||
apply(ctx) {
|
||||
let headerObject = Object.fromEntries([ctx.args]);
|
||||
headerObject = rewriteHeaders(headerObject);
|
||||
headerObject = rewriteHeaders(headerObject, client.meta);
|
||||
|
||||
ctx.args = Object.entries(headerObject)[0];
|
||||
},
|
||||
|
@ -18,7 +19,7 @@ export default function (client, self) {
|
|||
|
||||
client.Trap("XMLHttpRequest.prototype.responseURL", {
|
||||
get(ctx) {
|
||||
return decodeUrl(ctx.get());
|
||||
return decodeUrl(ctx.get() as string);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue