From c3ba4fa28a9f4d1f0b4f04030537be94680bdc83 Mon Sep 17 00:00:00 2001 From: Deepak Khatri <lorforlinux@beagleboard.org> Date: Sun, 24 Nov 2024 18:35:59 +0530 Subject: [PATCH] Fix 404 page --- _templates/404.html | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/_templates/404.html b/_templates/404.html index 21e5668f..a499f4dd 100644 --- a/_templates/404.html +++ b/_templates/404.html @@ -10,7 +10,6 @@ let currentUrl = window.location.href; // Iterate over the redirect_folders key-value pairs - let redirectFound = false; for (const [key, value] of Object.entries(redirectFolders)) { if (currentUrl.includes("/" + key)) { // Determine the replacement value @@ -23,9 +22,6 @@ fetch(newUrl, { method: "HEAD" }) .then(response => { if (response.ok) { - // Redirect is found - redirectFound = true; - // Update the heading with the correct information const headingElement = document.getElementById('pageHeading'); if (headingElement) { @@ -90,7 +86,8 @@ countdownActive = false; clearInterval(countdownInterval); }); - } else if (!redirectFound) { + } else { + // In case response is not OK const headingElement = document.getElementById('pageHeading'); if (headingElement) { headingElement.textContent = "Page Not Found (404)"; @@ -107,19 +104,14 @@ } document.getElementById('redirectInfo').style.display = "block"; }); - - // Stop after the first successful replacement check - break; - } - } - - // If no potential redirect match is found after iteration - if (!redirectFound) { - const headingElement = document.getElementById('pageHeading'); - if (headingElement) { - headingElement.textContent = "Page Not Found (404)"; + } else { + // In case the link test doesn't include redirectFolders + const headingElement = document.getElementById('pageHeading'); + if (headingElement) { + headingElement.textContent = "Page Not Found (404)"; + } + document.getElementById('redirectInfo').style.display = "block"; } - document.getElementById('redirectInfo').style.display = "block"; } </script> -- GitLab