Path: blob/main/corrosion/lib/browser/history.js
1223 views
function createHistoryRewriter(ctx) {1return function rewriteHistory() {2if (ctx.serviceWorker) return;3if (ctx.window.History.prototype.pushState) {4ctx.window.History.prototype.pushState = new Proxy(ctx.window.History.prototype.pushState, {5apply: (target, that, args) => {6if (args[2]) args[2] = ctx.url.wrap(args[2], ctx.meta);7const ret = Reflect.apply(target, that, args);8ctx.updateLocation();9return ret;10},11});12};13if (ctx.window.History.prototype.replaceState) {14ctx.window.History.prototype.replaceState = new Proxy(ctx.window.History.prototype.replaceState, {15apply: (target, that, args) => {16if (args[2]) args[2] = ctx.url.wrap(args[2], ctx.meta);17const ret = Reflect.apply(target, that, args);18ctx.updateLocation();19return ret;20},21});22};23};24};25module.exports = createHistoryRewriter;2627