fix: history proxy

This commit is contained in:
Percs 2024-11-02 22:43:56 -05:00
parent 7c55b59e5a
commit d632041355

View file

@ -5,7 +5,8 @@ import { UrlChangeEvent } from "../events";
export default function (client: ScramjetClient, self: typeof globalThis) { export default function (client: ScramjetClient, self: typeof globalThis) {
client.Proxy("History.prototype.pushState", { client.Proxy("History.prototype.pushState", {
apply(ctx) { apply(ctx) {
if (ctx.args[2]) ctx.args[2] = rewriteUrl(ctx.args[2], client.meta); if (ctx.args[2] || ctx.args[2] === "")
ctx.args[2] = rewriteUrl(ctx.args[2], client.meta);
ctx.call(); ctx.call();
const ev = new UrlChangeEvent(client.url.href); const ev = new UrlChangeEvent(client.url.href);
@ -15,7 +16,8 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
client.Proxy("History.prototype.replaceState", { client.Proxy("History.prototype.replaceState", {
apply(ctx) { apply(ctx) {
if (ctx.args[2]) ctx.args[2] = rewriteUrl(ctx.args[2], client.meta); if (ctx.args[2] || ctx.args[2] === "")
ctx.args[2] = rewriteUrl(ctx.args[2], client.meta);
ctx.call(); ctx.call();
const ev = new UrlChangeEvent(client.url.href); const ev = new UrlChangeEvent(client.url.href);