summaryrefslogtreecommitdiff
path: root/static/redirect.js
blob: e1387e23f132a34559fd02919b11b3bf16e5fdad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT

"use strict";

// Client-side redirects for fragments (anchors)
//
// It should be possible to do this with server-side redirects, but it was never implemented or
// standardized. For reference:
//
// 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"],
    ["/usage#default-connections", "/faq#default-connections"],
]);

function handle_hash() {
    if (window.location.hash) {
        const redirect = redirects.get(window.location.pathname + window.location.hash);
        if (redirect) {
            window.location.replace(redirect);
        }
    }
}

handle_hash();
addEventListener("hashchange", handle_hash, false);

// @license-end