-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path404.html
59 lines (59 loc) · 2 KB
/
404.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Single Page Apps for GitHub Pages</title>
<script type="text/javascript">
/**
* Single Page Apps for GitHub Pages
*
* Ref: https://github.com/rafrex/spa-github-pages
* Copyright (c) 2016 Rafael Pedicini, licensed under the MIT License
*
* This script takes the current URL, converts the path and query
* string into just a query string, and then redirects the browser
* to the new URL with only a query string and hash fragment.
*
* For example:
* http://www.foo.tld/one/two?a=b&c=d#qwe
* [BECOMES]
* http://www.foo.tld/?/one/two&q=a=b~and~c=d#qwe
*
* Note: This 404.html file must be at least 512 bytes for it to work
* with Internet Explorer (it is currently > 512 bytes).
*
* Note: If you are setting up a GitHub Pages site and not using a
* custom domain (i.e. your site's address is username.github.io/repo-name),
* then you need to set `pathSegmentsToKeep` to 1 in order to keep `/repo-name`
* in the path after the redirect. Otherwise, leave pathSegmentsToKeep as 0.
*
* For example:
* https://username.github.io/repo-name/one/two?a=b&c=d#qwe
* [BECOMES]
* https://username.github.io/repo-name/?/one/two&q=a=b~and~c=d#qwe
*/
let pathSegmentsToKeep = 0;
let l = window.location;
l.replace(
l.protocol +
"//" +
l.hostname +
(l.port ? ":" + l.port : "") +
l.pathname
.split("/")
.slice(0, 1 + pathSegmentsToKeep)
.join("/") +
"/?/" +
l.pathname
.slice(1)
.split("/")
.slice(pathSegmentsToKeep)
.join("/")
.replace(/&/g, "~and~") +
(l.search ? "&" + l.search.slice(1).replace(/&/g, "~and~") : "") +
l.hash
);
</script>
</head>
<body></body>
</html>