diff --git a/apps/site/components/withDownloadArchive.tsx b/apps/site/components/withDownloadArchive.tsx index 122042a16c42c..460150ead3948 100644 --- a/apps/site/components/withDownloadArchive.tsx +++ b/apps/site/components/withDownloadArchive.tsx @@ -1,6 +1,5 @@ import { notFound } from 'next/navigation'; import type { FC } from 'react'; -import semVer from 'semver'; import { getClientContext } from '#site/client-context'; import provideReleaseData from '#site/next-data/providers/releaseData'; @@ -27,16 +26,17 @@ const WithDownloadArchive: FC = async ({ // Extract version from pathname const version = extractVersionFromPath(pathname); - if (version == null) { - return notFound(); - } - // Find the release data for the given version const releaseData = provideReleaseData(); - const release = releaseData.find( - release => semVer.major(version) === release.major + const release = releaseData.find(release => + // Match major version only (e.g., v22.x.x for release.major v22) + version.startsWith(`v${release.major}`) )!; + if (!release) { + return notFound(); + } + const releaseArtifacts = buildReleaseArtifacts(release, version); return ; diff --git a/apps/site/pages/en/download/archive/index.mdx b/apps/site/pages/en/download/archive/index.mdx index 480a1564e7c5e..e8a0ea76c9537 100644 --- a/apps/site/pages/en/download/archive/index.mdx +++ b/apps/site/pages/en/download/archive/index.mdx @@ -24,7 +24,9 @@ layout: download-archive
    - +
  • + Read the changelog or blog post for this version. +
  • Learn more about Node.js releases, including the release schedule and LTS status.
  • diff --git a/apps/site/util/download/archive.tsx b/apps/site/util/download/archive.tsx index 15d6e407bb75b..643f49ddadbba 100644 --- a/apps/site/util/download/archive.tsx +++ b/apps/site/util/download/archive.tsx @@ -140,19 +140,10 @@ export const buildReleaseArtifacts = ( * Extracts the version from the pathname. * It expects the version to be in the format like 'v22.0.4'. */ -export const extractVersionFromPath = (pathname: string | undefined) => { - if (!pathname) { - return null; - } - +export const extractVersionFromPath = (pathname: string) => { const segments = pathname.split('/').filter(Boolean); - const version = segments.pop(); - - // Checks the version prefix + digits + optional dot-separated digits - // (v22, v22.0.4) - if (!version || !version.match(/^v\d+(\.\d+)*$/)) { - return null; - } + // The version is expected to be the last segment in the path + const version = segments.pop()!; return version; };