fix: url rewriting

This commit is contained in:
Percs 2024-11-21 09:17:31 -06:00
parent 8b8c9b4741
commit e9f4e59566

View file

@ -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!!!
const realUrl = tryCanParseURL(url, base);
if (realUrl) {
return (
location.origin +
$scramjet.config.prefix +
$scramjet.codec.encode(new URL(url, base).href)
$scramjet.codec.encode(realUrl.href)
);
} else {
return url;
}
}
}