File size: 837 Bytes
bee6636 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import { rewriteUrl } from "../../shared/rewriters/url";
import { ScramjetClient } from "../client";
import { UrlChangeEvent } from "../events";
export default function (client: ScramjetClient, _self: Self) {
client.Proxy("History.prototype.pushState", {
apply(ctx) {
if (ctx.args[2] || ctx.args[2] === "")
ctx.args[2] = rewriteUrl(ctx.args[2], client.meta);
ctx.call();
const ev = new UrlChangeEvent(client.url.href);
if (!client.isSubframe) client.frame?.dispatchEvent(ev);
},
});
client.Proxy("History.prototype.replaceState", {
apply(ctx) {
if (ctx.args[2] || ctx.args[2] === "")
ctx.args[2] = rewriteUrl(ctx.args[2], client.meta);
ctx.call();
const ev = new UrlChangeEvent(client.url.href);
if (!client.isSubframe) client.frame?.dispatchEvent(ev);
},
});
}
|