mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-15 23:30:00 -04:00
misc refactors
This commit is contained in:
parent
819c1701d0
commit
0939dd2b57
25 changed files with 82 additions and 66 deletions
|
@ -6,7 +6,7 @@ import { createGlobalProxy } from "./global";
|
|||
import { getOwnPropertyDescriptorHandler } from "./helpers";
|
||||
import { createLocationProxy } from "./location";
|
||||
import { nativeGetOwnPropertyDescriptor } from "./natives";
|
||||
import { CookieStore, config, decodeUrl } from "./shared";
|
||||
import { CookieStore, config, decodeUrl, encodeUrl } from "../shared";
|
||||
import { createWrapFn } from "./shared/wrap";
|
||||
|
||||
declare global {
|
||||
|
@ -135,6 +135,20 @@ export class ScramjetClient {
|
|||
}
|
||||
}
|
||||
|
||||
get url(): URL {
|
||||
return new URL(decodeUrl(self.location.href));
|
||||
}
|
||||
|
||||
set url(url: URL | string) {
|
||||
if (typeof url === "string") url = new URL(url);
|
||||
|
||||
self.location.href = encodeUrl(url.href);
|
||||
}
|
||||
|
||||
// below are the utilities for proxying and trapping dom APIs
|
||||
// you don't have to understand this it just makes the rest easier
|
||||
// i'll document it eventually
|
||||
|
||||
Proxy(name: string | string[], handler: Proxy) {
|
||||
if (Array.isArray(name)) {
|
||||
for (const n of name) {
|
||||
|
@ -320,8 +334,4 @@ export class ScramjetClient {
|
|||
|
||||
return oldDescriptor;
|
||||
}
|
||||
|
||||
get url(): URL {
|
||||
return new URL(decodeUrl(location.href));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue