This commit is contained in:
Avad3 2024-07-14 05:16:54 -04:00
parent 555ae496a5
commit b448c5505b
20 changed files with 104 additions and 71 deletions

View file

@ -1,18 +1,26 @@
// @ts-nocheck
import { encodeUrl, decodeUrl } from "../shared";
import { encodeUrl, decodeUrl } from "./index";
const loc = new URL(decodeUrl(location.href));
loc.assign = (url: string) => location.assign(encodeUrl(url));
loc.reload = () => location.reload();
loc.replace = (url: string) => location.replace(encodeUrl(url));
loc.toString = () => loc.href;
function createLocation() {
const loc = new URL(decodeUrl(location.href));
loc.assign = (url: string) => location.assign(encodeUrl(url));
loc.reload = () => location.reload();
loc.replace = (url: string) => location.replace(encodeUrl(url));
loc.toString = () => loc.href;
return loc;
}
export const locationProxy = new Proxy(window.location, {
get(target, prop) {
const loc = createLocation();
return loc[prop];
},
set(obj, prop, value) {
const loc = createLocation();
if (prop === "href") {
location.href = encodeUrl(value);
} else {