Skip to content

Commit

Permalink
fix: url rewriting
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Nov 21, 2024
1 parent 8b8c9b4 commit e9f4e59
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/shared/rewriters/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit e9f4e59

Please sign in to comment.