mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 23:10:02 -04:00
prettier
This commit is contained in:
parent
4b0337db0c
commit
55b6666229
43 changed files with 4693 additions and 2712 deletions
|
@ -2,32 +2,31 @@
|
|||
import { encodeUrl, decodeUrl } from "./shared";
|
||||
|
||||
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;
|
||||
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;
|
||||
return loc;
|
||||
}
|
||||
|
||||
export const locationProxy = new Proxy(window.location, {
|
||||
get(target, prop) {
|
||||
const loc = createLocation();
|
||||
get(target, prop) {
|
||||
const loc = createLocation();
|
||||
|
||||
return loc[prop];
|
||||
},
|
||||
return loc[prop];
|
||||
},
|
||||
|
||||
set(obj, prop, value) {
|
||||
const loc = createLocation();
|
||||
|
||||
if (prop === "href") {
|
||||
location.href = encodeUrl(value);
|
||||
} else {
|
||||
loc[prop] = value;
|
||||
}
|
||||
set(obj, prop, value) {
|
||||
const loc = createLocation();
|
||||
|
||||
return true;
|
||||
if (prop === "href") {
|
||||
location.href = encodeUrl(value);
|
||||
} else {
|
||||
loc[prop] = value;
|
||||
}
|
||||
})
|
||||
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue