(function () { var l = window.location; var sp = new URLSearchParams(l.search); var p = sp.get("p"); // "/original/path" (may include trailing slash) if (!p) return; var q = sp.get("q") || ""; if (q) q = q.replace(/~and~/g, "&"); // normalize p if (p[0] !== "/") p = "/" + p; if (p.length > 1) p = p.replace(/\/+$/, ""); // drop trailing slash (except "/") var newUrl = p + (q ? "?" + q : "") + l.hash; // make router see the correct path history.replaceState(null, "", newUrl); })(); ead>