mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 15:00:01 -04:00
fix: url rewriting
This commit is contained in:
parent
8b8c9b4741
commit
e9f4e59566
1 changed files with 10 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue