From e9f4e59566d63625048d1398a60850b8382e2b98 Mon Sep 17 00:00:00 2001 From: Percs <83934299+Percslol@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:17:31 -0600 Subject: [PATCH] fix: url rewriting --- src/shared/rewriters/url.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/shared/rewriters/url.ts b/src/shared/rewriters/url.ts index 67dfd7a..7b54e8b 100644 --- a/src/shared/rewriters/url.ts +++ b/src/shared/rewriters/url.ts @@ -45,12 +45,16 @@ export function rewriteUrl(url: string | URL, meta: URLMeta) { let base = meta.base.href; if (base.startsWith("about:")) base = unrewriteUrl(self.location.href); // jank!!!!! weird jank!!! - - return ( - location.origin + - $scramjet.config.prefix + - $scramjet.codec.encode(new URL(url, base).href) - ); + const realUrl = tryCanParseURL(url, base); + if (realUrl) { + return ( + location.origin + + $scramjet.config.prefix + + $scramjet.codec.encode(realUrl.href) + ); + } else { + return url; + } } }