From f53bc623ffbc1e1ba083b7f7999dfb50e846e5c6 Mon Sep 17 00:00:00 2001 From: Percs <83934299+Percslol@users.noreply.github.com> Date: Mon, 15 Jul 2024 00:41:43 -0500 Subject: [PATCH] fix some url rewriters --- src/client/index.ts | 1 - src/client/url.ts | 13 ------------- src/shared/rewriters/url.ts | 7 +++---- 3 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 src/client/url.ts diff --git a/src/client/index.ts b/src/client/index.ts index 3db716d..e7ee693 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -12,7 +12,6 @@ import "./storage.ts"; import "./css.ts"; import "./history.ts"; import "./worker.ts"; -import "./url.ts"; import "./beacon.ts" declare global { diff --git a/src/client/url.ts b/src/client/url.ts deleted file mode 100644 index 35a497f..0000000 --- a/src/client/url.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { encodeUrl } from "../shared/rewriters/url"; -export const URL = globalThis.URL; - -if (globalThis.window) { - window.URL = new Proxy(URL, { - construct(target, argArray, newTarget) { - if (typeof argArray[0] === "string") argArray[0] = encodeUrl(argArray[0]); - if (typeof argArray[1] === "string") argArray[1] = encodeUrl(argArray[1]); - - return Reflect.construct(target, argArray, newTarget); - }, - }); -} diff --git a/src/shared/rewriters/url.ts b/src/shared/rewriters/url.ts index fa41a56..74cd1ea 100644 --- a/src/shared/rewriters/url.ts +++ b/src/shared/rewriters/url.ts @@ -1,5 +1,4 @@ -import { URL } from "../../client/url"; -import { rewriteJs } from "./js"; +;import { rewriteJs } from "./js"; function canParseUrl(url: string, origin?: URL) { try { @@ -14,7 +13,7 @@ function canParseUrl(url: string, origin?: URL) { // something is broken with this but i didn't debug it export function encodeUrl(url: string | URL, origin?: URL) { if (url instanceof URL) { - return url.toString(); + url = url.href; } if (!origin) { @@ -46,7 +45,7 @@ export function encodeUrl(url: string | URL, origin?: URL) { // something is also broken with this but i didn't debug it export function decodeUrl(url: string | URL) { if (url instanceof URL) { - return url.toString(); + url = url.href; } if (/^(#|about|data|mailto|javascript)/.test(url)) {