mirror of
https://github.com/n8n-io/n8n-docs.git
synced 2025-11-20 17:48:34 +00:00
handle uppercase paths (#3740)
This commit is contained in:
parent
35af91b7a5
commit
b7ab8773a1
@ -2,7 +2,44 @@
|
||||
{% block htmltitle %}
|
||||
<title>404</title>
|
||||
{% endblock %}
|
||||
{% block extrahead %}
|
||||
<script>
|
||||
// Create an object containing redirects to headings
|
||||
const redirects = {
|
||||
|
||||
};
|
||||
|
||||
(function redirect(){
|
||||
const incomingPath = window.location.pathname;
|
||||
const hasExtension = /\.[a-zA-Z0-9]+$/.test(incomingPath);
|
||||
|
||||
// handle uppercase URLs
|
||||
if (incomingPath !== incomingPath.toLowerCase()) {
|
||||
const lowercasePath = incomingPath.toLowerCase();
|
||||
window.location.href = `${window.location.origin}${lowercasePath}`;
|
||||
return;
|
||||
}
|
||||
|
||||
// handle missing trailing `/`
|
||||
if (!incomingPath.endsWith('/') && !hasExtension) {
|
||||
window.location.href = `${window.location.origin}${incomingPath}/`;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// handle redirects for headings
|
||||
const currentPath = incomingPath + (window.location.hash ? window.location.hash : '');
|
||||
const redirectUrl = redirects[currentPath];
|
||||
if (redirectUrl) {
|
||||
window.location.href = `${window.location.origin}${redirectUrl}`;
|
||||
return;
|
||||
}
|
||||
})();
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<h1>404 - Page not found</h1>
|
||||
<h2>Go <a href="/">home</a></h2>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
Loading…
Reference in New Issue
Block a user