mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-17 08:00:02 -04:00
rename encodeUrl to rewriteUrl
This commit is contained in:
parent
839b490c80
commit
3062db5df9
26 changed files with 78 additions and 75 deletions
|
@ -1,10 +1,10 @@
|
|||
import { encodeUrl } from "../../../shared/rewriters/url";
|
||||
import { rewriteUrl } from "../../../shared";
|
||||
import { ScramjetClient } from "../../client";
|
||||
|
||||
export default function (client: ScramjetClient, self) {
|
||||
client.Proxy("navigator.sendBeacon", {
|
||||
apply(ctx) {
|
||||
ctx.args[0] = encodeUrl(ctx.args[0], client.meta);
|
||||
ctx.args[0] = rewriteUrl(ctx.args[0], client.meta);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
import { decodeUrl, encodeUrl } from "../../../shared";
|
||||
import { unrewriteUrl, rewriteUrl } from "../../../shared";
|
||||
import { ScramjetClient } from "../../client";
|
||||
|
||||
export default function (client: ScramjetClient) {
|
||||
client.Proxy("EventSource", {
|
||||
construct(ctx) {
|
||||
ctx.args[0] = encodeUrl(ctx.args[0], client.meta);
|
||||
ctx.args[0] = rewriteUrl(ctx.args[0], client.meta);
|
||||
},
|
||||
});
|
||||
|
||||
client.Trap("EventSource.prototype.url", {
|
||||
get(ctx) {
|
||||
decodeUrl(ctx.get() as string);
|
||||
unrewriteUrl(ctx.get() as string);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
// ts throws an error if you dont do window.fetch
|
||||
|
||||
import { isemulatedsw } from "../..";
|
||||
import { decodeUrl } from "../../../shared/rewriters/url";
|
||||
import { unrewriteUrl } from "../../../shared";
|
||||
import { ScramjetClient } from "../../client";
|
||||
import { encodeUrl, rewriteHeaders } from "../../../shared";
|
||||
import { rewriteUrl, rewriteHeaders } from "../../../shared";
|
||||
|
||||
export default function (client: ScramjetClient, self: typeof globalThis) {
|
||||
client.Proxy("fetch", {
|
||||
apply(ctx) {
|
||||
if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) {
|
||||
ctx.args[0] = encodeUrl(ctx.args[0].toString(), client.meta);
|
||||
ctx.args[0] = rewriteUrl(ctx.args[0].toString(), client.meta);
|
||||
|
||||
if (isemulatedsw) ctx.args[0] += "?from=swruntime";
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
|
|||
client.Proxy("Request", {
|
||||
construct(ctx) {
|
||||
if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) {
|
||||
ctx.args[0] = encodeUrl(ctx.args[0].toString(), client.meta);
|
||||
ctx.args[0] = rewriteUrl(ctx.args[0].toString(), client.meta);
|
||||
|
||||
if (isemulatedsw) ctx.args[0] += "?from=swruntime";
|
||||
}
|
||||
|
@ -34,13 +34,13 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
|
|||
|
||||
client.Trap("Response.prototype.url", {
|
||||
get(ctx) {
|
||||
return decodeUrl(ctx.get() as string);
|
||||
return unrewriteUrl(ctx.get() as string);
|
||||
},
|
||||
});
|
||||
|
||||
client.Trap("Request.prototype.url", {
|
||||
get(ctx) {
|
||||
return decodeUrl(ctx.get() as string);
|
||||
return unrewriteUrl(ctx.get() as string);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { config, decodeUrl, encodeUrl } from "../../../shared";
|
||||
import { config, unrewriteUrl, rewriteUrl } from "../../../shared";
|
||||
import { ScramjetClient } from "../../client";
|
||||
let nativeworker;
|
||||
let postmessage;
|
||||
|
@ -18,7 +18,7 @@ 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], client.meta);
|
||||
if (ctx.args[1]) ctx.args[1] = rewriteUrl(ctx.args[1], client.meta);
|
||||
ctx.this[ARGS] = ctx.args;
|
||||
},
|
||||
});
|
||||
|
@ -128,7 +128,7 @@ export default function (client: ScramjetClient, self: Self) {
|
|||
|
||||
client.Trap("XMLHttpRequest.prototype.responseURL", {
|
||||
get(ctx) {
|
||||
return decodeUrl(ctx.get() as string);
|
||||
return unrewriteUrl(ctx.get() as string);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue