-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploying to main from @ 870569161c0a5c302511f7910e8dd2e0056137e9 🚀
- Loading branch information
Showing
3 changed files
with
75 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
var pageWithHash = window.location.pathname + window.location.hash; | ||
var page = window.location.pathname; | ||
var openRedirects = new XMLHttpRequest(); | ||
openRedirects.onreadystatechange = function() { | ||
if (this.readyState === 4 && this.status === 200) { | ||
var redirects = this.responseText.split(/\r?\n/); | ||
for (var i = 0; i < redirects.length; i++) { | ||
var redirect = redirects[i].split("="); | ||
if (redirects[i].trim().startsWith("#")) { | ||
// allow for line comments | ||
continue; | ||
} | ||
var pattern = new RegExp(redirect[0]) | ||
if (pattern.test(page) || pattern.test(pageWithHash)) { | ||
document.title = "Redirecting..." | ||
document.getElementById("heading").innerText = "Redirecting..."; | ||
document.getElementById("redirecting").style.display = "block"; | ||
document.getElementById("notfound").style.display = "none"; | ||
document.getElementById("redirectlink").href = redirect[1]; | ||
document.getElementById("redirectlink").innerText = redirect[1]; | ||
var anchor = ""; | ||
if (redirect[1].indexOf("#") !== -1) { | ||
anchor = "#" + redirect[1].split("#")[1]; | ||
} | ||
var checkRedirect = new XMLHttpRequest(); | ||
checkRedirect.onreadystatechange = function() { | ||
if (this.readyState === 4) { | ||
if (this.status === 200) { | ||
// The response URL will no longer contain the anchor, therefore, add it again | ||
window.location = checkRedirect.responseURL + anchor; | ||
} else { | ||
document.getElementById("heading").innerText = "Redirect failed"; | ||
document.getElementById("notfound").style.display = "block"; | ||
document.getElementById("redirecting").style.display = "none"; | ||
} | ||
} | ||
} | ||
checkRedirect.open("GET", redirect[1], true); | ||
checkRedirect.send(); | ||
break; | ||
} | ||
} | ||
} | ||
}; | ||
openRedirects.open("GET", "/resources/redirects", true); | ||
openRedirects.send(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Regex with with or without a anchor -> target path | ||
^/docs/(latest|[0-9.]+)/securing_apps=/guides.html#securing-apps | ||
^/docs/(latest|[0-9.]+)/server_installation=/guides.html#server | ||
^/docs/(latest|[0-9.]+)/getting_started=/guides.html#getting-started | ||
^/docs/([0-9.]+)/server-admin=/docs-api/latest/server-admin/index.html | ||
^/docs/([0-9.]+)/upgrading=/docs-api/latest/upgrading/index.html | ||
^/docs-api/[0-9.]+/rest-api=/docs-api/latest/rest-api/index.html | ||
^/[0-9]+/[0-9]+/keycloak-[0-9]+-released=/blog.html | ||
^/404=/ |