Repository navigation
Expand file tree
/
Copy path404.html
More file actions
69 lines (64 loc) · 3.08 KB
/
Copy path404.html
File metadata and controls
69 lines (64 loc) · 3.08 KB
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
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Only this page's own inline script and style may run; nothing is loaded -->
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'">
<meta name="referrer" content="strict-origin-when-cross-origin">
<title>Page not found | carterscoding</title>
<meta name="robots" content="noindex">
<!-- Colors here repeat --c-bg, --c-text and --c-accent from styles.css (this
page can't load styles.css from every possible URL depth) -->
<meta name="theme-color" content="#050806">
<!-- GitHub Pages serves this file for any URL that doesn't exist.
It sends the visitor straight to the homepage, which shows a
"you've been redirected" banner (see section 6 of script.js). -->
<script>
// The homepage is "/" on carterscoding.com. If the custom domain is ever
// removed, GitHub serves the site from cksarge.github.io/Homepage/ instead.
var home = /\.github\.io$/.test(window.location.hostname) ? "/Homepage/" : "/";
var path = window.location.pathname;
// Hand the bad URL to the homepage through sessionStorage rather than the
// address bar, so a link to the bare homepage can't show a fake banner and
// no extra homepage URLs exist. (A link to a made-up path still shows that
// path in the banner; script.js keeps it short and plain.) The timestamp
// lets the homepage ignore an entry left over from an earlier redirect.
// The key must match NOT_FOUND_KEY in script.js (section 6).
// Opening /404.html itself isn't a bad URL, so it gets no banner.
if (!/\/404\.html$/.test(path)) {
try {
window.sessionStorage.setItem(
"carterscoding:notfound",
JSON.stringify({ path: path + window.location.search + window.location.hash, t: Date.now() })
);
} catch (e) { /* storage blocked: still redirect, just without the banner */ }
}
// replace() keeps the bad URL out of the Back button's history.
// (If the homepage itself is ever missing, stay here rather than loop.)
if (path !== home) window.location.replace(home);
</script>
<!-- No JavaScript: redirect anyway (the homepage just won't show the banner).
This can't know the github.io folder above, so it always goes to "/". -->
<noscript><meta http-equiv="refresh" content="0; url=/"></noscript>
<style>
body {
margin: 0;
min-height: 100vh;
display: grid;
place-items: center;
padding: 16px;
background: #050806;
color: #dcffe9;
font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
text-align: center;
}
a { color: #00ff9c; }
</style>
</head>
<body>
<!-- Only seen for a moment, or if the redirect is blocked -->
<p>That page doesn't exist. Taking you to <a id="home-link" href="/">the homepage</a>…</p>
<script>document.getElementById("home-link").href = home;</script>
</body>
</html>