mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 06:20:02 -04:00
dont append hash to every single url
This commit is contained in:
parent
c2de733549
commit
f329714037
1 changed files with 4 additions and 3 deletions
|
@ -47,14 +47,14 @@ export function rewriteUrl(url: string | URL, meta: URLMeta) {
|
||||||
const realUrl = tryCanParseURL(url, base);
|
const realUrl = tryCanParseURL(url, base);
|
||||||
if (!realUrl) return url;
|
if (!realUrl) return url;
|
||||||
const encodedHash = $scramjet.codec.encode(realUrl.hash.slice(1));
|
const encodedHash = $scramjet.codec.encode(realUrl.hash.slice(1));
|
||||||
|
const realHash = encodedHash ? "#" + encodedHash : "";
|
||||||
realUrl.hash = "";
|
realUrl.hash = "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
location.origin +
|
location.origin +
|
||||||
$scramjet.config.prefix +
|
$scramjet.config.prefix +
|
||||||
$scramjet.codec.encode(realUrl.href) +
|
$scramjet.codec.encode(realUrl.href) +
|
||||||
"#" +
|
realHash
|
||||||
encodedHash
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,10 +80,11 @@ export function unrewriteUrl(url: string | URL) {
|
||||||
const realUrl = tryCanParseURL(url);
|
const realUrl = tryCanParseURL(url);
|
||||||
if (!realUrl) return url;
|
if (!realUrl) return url;
|
||||||
const decodedHash = $scramjet.codec.decode(realUrl.hash.slice(1));
|
const decodedHash = $scramjet.codec.decode(realUrl.hash.slice(1));
|
||||||
|
const realHash = decodedHash ? "#" + decodedHash : "";
|
||||||
realUrl.hash = "";
|
realUrl.hash = "";
|
||||||
|
|
||||||
return $scramjet.codec.decode(
|
return $scramjet.codec.decode(
|
||||||
realUrl.href.slice(prefixed.length) + "#" + decodedHash
|
realUrl.href.slice(prefixed.length) + realHash
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue