summaryrefslogtreecommitdiff
path: root/static/js/redirect.js
blob: a8060dcbceca5e32f8cd0201cdd5c347175ddbd9 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT

// 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"],
    ["/#roadmap", "/faq#roadmap"],
    ["/#upstream", "/faq#upstream"],
    ["/#copyright-and-licensing", "/faq#copyright-and-licensing"],
    ["/#history", "/history#history"],
    ["/usage#default-connections", "/faq#default-connections"],
    ["/releases#marlin-stable", "/faq#legacy-devices"],
    ["/releases#sailfish-stable", "/faq#legacy-devices"],
    ["/releases#marlin-beta", "/faq#legacy-devices"],
    ["/releases#sailfish-beta", "/faq#legacy-devices"],
    ["/faq#dns", "/faq#custom-dns"],
    ["/build#upgrading-to-android-10", "/build#generating-release-signing-keys"],
    ["/install/cli#fastboot-as-non-root", "/install/cli#flashing-as-non-root"],
    ["/install/web#fastboot-as-non-root", "/install/web#flashing-as-non-root"],

    // preserve links to CLI install guide from when it was /install
    ["/install/#prerequisites", "/install/cli#prerequisites"],
    ["/install/#enabling-oem-unlocking", "/install/cli#enabling-oem-unlocking"],
    ["/install/#opening-terminal", "/install/cli#opening-terminal"],
    ["/install/#obtaining-fastboot", "/install/cli#obtaining-fastboot"],
    ["/install/#standalone-platform-tools", "/install/cli#standalone-platform-tools"],
    ["/install/#checking-fastboot-version", "/install/cli#checking-fastboot-version"],
    ["/install/#fastboot-as-non-root", "/install/cli#fastboot-as-non-root"],
    ["/install/#connecting-phone", "/install/cli#connecting-phone"],
    ["/install/#unlocking-the-bootloader", "/install/cli#unlocking-the-bootloader"],
    ["/install/#obtaining-signify", "/install/cli#obtaining-signify"],
    ["/install/#obtaining-factory-images", "/install/cli#obtaining-factory-images"],
    ["/install/#flashing-factory-images", "/install/cli#flashing-as-non-root"],
    ["/install/#troubleshooting", "/install/cli#troubleshooting"],
    ["/install/#locking-the-bootloader", "/install/cli#locking-the-bootloader"],
    ["/install/#post-installation", "/install/cli#post-installation"],
    ["/install/#booting", "/install/cli#booting"],
    ["/install/#disabling-oem-unlocking", "/install/cli#disabling-oem-unlocking"],
    ["/install/#replacing-grapheneos-with-the-stock-os", "/install/cli#replacing-grapheneos-with-the-stock-os"],
    ["/install/#further-information", "/install/cli#further-information"],
]);

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