-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathcustom404.html
More file actions
44 lines (37 loc) · 1.19 KB
/
custom404.html
File metadata and controls
44 lines (37 loc) · 1.19 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting</title>
<noscript>
<meta http-equiv="refresh" content="1; url=https://ui5.github.io/cli" />
</noscript>
<script>
(function name(params) {
"use strict";
var url = new URL(window.location);
var path = url.pathname.split("/");
var pathRegex = /\/cli\/(v[0-9]+|stable|next)/gi
// For "old" links- keep the path but try to redirect to the stable release
if (!url.pathname.match(pathRegex)) {
path.splice(2, 0, "stable");
} else {
// Path is not found in the stable release and no version is provided.
// Then show the versioned 404 page, so the end user would still be in the same version
var versionIndex = path.findIndex((elem) => elem.match(/^(v[0-9]+|stable|next)$/))
if (versionIndex > -1) {
path.splice((versionIndex + 1), path.length, "404")
} else {
// Edge case: redirect to the stable version i.e. /cli/v28372389/
path = ["cli", "stable", "404"];
}
}
url.pathname = path.join("/");
window.location = url.toString();
})()
</script>
</head>
<body>
Redirect to <a href="https://ui5.github.io/cli/stable/">the stable docs release/</a>...
</body>
</html>