From 5366a914103db38be755bafb4a781b702dfba822 Mon Sep 17 00:00:00 2001 From: Caner Akdas Date: Fri, 29 Aug 2025 16:23:50 +0300 Subject: [PATCH 1/3] refactor: extra checks removed, changelog added --- apps/site/components/withDownloadArchive.tsx | 11 +++-------- apps/site/pages/en/download/archive/index.mdx | 4 +++- apps/site/util/download/archive.tsx | 15 +++------------ 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/apps/site/components/withDownloadArchive.tsx b/apps/site/components/withDownloadArchive.tsx index 122042a16c42c..b5f394733eaf5 100644 --- a/apps/site/components/withDownloadArchive.tsx +++ b/apps/site/components/withDownloadArchive.tsx @@ -1,6 +1,4 @@ -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,14 +25,11 @@ 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}`) )!; const releaseArtifacts = buildReleaseArtifacts(release, version); 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 bb6156254c191..36e107a66052f 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; }; From a9d550f6e1189da2f8c4234b49d535d2d860ee70 Mon Sep 17 00:00:00 2001 From: Caner Akdas Date: Wed, 3 Sep 2025 21:23:11 +0300 Subject: [PATCH 2/3] chore: redirect archive index page --- apps/site/redirects.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/site/redirects.json b/apps/site/redirects.json index 3698f577095fe..5cf63fdb8ca05 100644 --- a/apps/site/redirects.json +++ b/apps/site/redirects.json @@ -332,6 +332,10 @@ "source": "/:locale/download/source-code/current", "destination": "/:locale/download/current" }, + { + "source": "/:locale/download/archive", + "destination": "/:locale/download/archive/current" + }, { "source": "/discord", "destination": "https://discord.gg/nodejs" From 03b2a931b6c3023d00c7438a6c2e507b979be301 Mon Sep 17 00:00:00 2001 From: Caner Akdas Date: Wed, 3 Sep 2025 22:28:15 +0300 Subject: [PATCH 3/3] chore: release check added --- apps/site/components/withDownloadArchive.tsx | 5 +++++ apps/site/redirects.json | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/site/components/withDownloadArchive.tsx b/apps/site/components/withDownloadArchive.tsx index b5f394733eaf5..460150ead3948 100644 --- a/apps/site/components/withDownloadArchive.tsx +++ b/apps/site/components/withDownloadArchive.tsx @@ -1,3 +1,4 @@ +import { notFound } from 'next/navigation'; import type { FC } from 'react'; import { getClientContext } from '#site/client-context'; @@ -32,6 +33,10 @@ const WithDownloadArchive: FC = async ({ version.startsWith(`v${release.major}`) )!; + if (!release) { + return notFound(); + } + const releaseArtifacts = buildReleaseArtifacts(release, version); return ; diff --git a/apps/site/redirects.json b/apps/site/redirects.json index 5cf63fdb8ca05..3698f577095fe 100644 --- a/apps/site/redirects.json +++ b/apps/site/redirects.json @@ -332,10 +332,6 @@ "source": "/:locale/download/source-code/current", "destination": "/:locale/download/current" }, - { - "source": "/:locale/download/archive", - "destination": "/:locale/download/archive/current" - }, { "source": "/discord", "destination": "https://discord.gg/nodejs"