 Construct the new URL.
                // Example: /A2A/specification.md -> /A2A/latest/specification.md
                const newPath = path.replace(basePath, basePath + latestVersion + '/');

                // Store a marker in sessionStorage to prevent loops
                sessionStorage.setItem('redirected', 'true');

                // Perform the redirect
                window.location.replace(newPath + window.location.search + window.location.hash);
            } else {
                window.loc