generic anchor redirect code

This commit is contained in:
Daniel Micay 2020-02-14 16:22:45 -05:00
parent 09488a2018
commit e81f367be6
2 changed files with 10 additions and 3 deletions

View File

@ -114,6 +114,6 @@
<li><a href="https://reddit.com/r/GrapheneOS">Reddit</a></li>
</ul>
</footer>
<script src="/redirect.js?0"></script>
<script src="/redirect.js?1"></script>
</body>
</html>

View File

@ -10,9 +10,16 @@
// https://www.w3.org/People/Bos/redirect
// https://www.w3.org/Protocols/HTTP/Fragment/draft-bos-http-redirect-00.txt
const redirects = new Map([
["/#device-support", "/faq#device-support"],
]);
function handle_hash() {
if (window.location.hash === "#device-support") {
window.location.replace("https://grapheneos.org/faq#device-support");
if (window.location.hash) {
const redirect = redirects.get(window.location.pathname + window.location.hash);
if (redirect) {
window.location.replace(redirect);
}
}
}