Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.
Fix Overly broad 404 path check skips styled error page
Louis Choquel2cfb386bb883
diff --git a/docs/404.html b/docs/404.htmlindex 13be3fb58..d1a22c4be 100644--- a/docs/404.html+++ b/docs/404.html@@ -5,25 +5,26 @@<title>Redirecting...</title><script>const path = window.location.pathname;- // Get the first path segment (e.g., "/latest/foo/bar" → "latest")- const firstSegment = path.split('/').filter(seg => seg)[0];+ // Get path segments (e.g., "/latest/foo/bar" → ["latest", "foo", "bar"])+ const segments = path.split('/').filter(seg => seg);+ const firstSegment = segments[0];// Check if it's a version: either "latest" or starts with "0." (e.g., "0.17")const hasVersion = firstSegment === 'latest' || (firstSegment && firstSegment.startsWith('0.'));- // Check if we're already on a 404.html path (prevents infinite loop for invalid versions)- const isAlready404 = path.endsWith('/404.html');+ // Check if we're on a version's root 404 page (exactly /{version}/404.html)+ const isVersionRoot404 = segments.length === 2 && segments[1] === '404.html';if (!hasVersion) {// No version in URL, redirect to /latest/...const newUrl = '/latest' + path + window.location.search + window.location.hash;window.location.replace(newUrl);- } else if (isAlready404 && firstSegment !== 'latest') {+ } else if (isVersionRoot404 && firstSegment !== 'latest') {// We tried a version's 404.html but it doesn't exist (invalid version)// Fall back to /latest/404.htmlwindow.location.replace('/latest/404.html');- } else if (!isAlready404) {- // Has version, redirect to that version's styled 404 page+ } else if (!isVersionRoot404) {+ // Has version but not on 404 page, redirect to that version's styled 404 pageconst version404Url = '/' + firstSegment + '/404.html';window.location.replace(version404Url);} else {