File tree Expand file tree Collapse file tree 3 files changed +13
-20
lines changed
pages/en/download/archive Expand file tree Collapse file tree 3 files changed +13
-20
lines changed Original file line number Diff line number Diff line change 1
1
import { notFound } from 'next/navigation' ;
2
2
import type { FC } from 'react' ;
3
- import semVer from 'semver' ;
4
3
5
4
import { getClientContext } from '#site/client-context' ;
6
5
import provideReleaseData from '#site/next-data/providers/releaseData' ;
@@ -27,16 +26,17 @@ const WithDownloadArchive: FC<WithDownloadArchiveProps> = async ({
27
26
// Extract version from pathname
28
27
const version = extractVersionFromPath ( pathname ) ;
29
28
30
- if ( version == null ) {
31
- return notFound ( ) ;
32
- }
33
-
34
29
// Find the release data for the given version
35
30
const releaseData = provideReleaseData ( ) ;
36
- const release = releaseData . find (
37
- release => semVer . major ( version ) === release . major
31
+ const release = releaseData . find ( release =>
32
+ // Match major version only (e.g., v22.x.x for release.major v22)
33
+ version . startsWith ( `v${ release . major } ` )
38
34
) ! ;
39
35
36
+ if ( ! release ) {
37
+ return notFound ( ) ;
38
+ }
39
+
40
40
const releaseArtifacts = buildReleaseArtifacts ( release , version ) ;
41
41
42
42
return < Component { ...releaseArtifacts } /> ;
Original file line number Diff line number Diff line change @@ -24,7 +24,9 @@ layout: download-archive
24
24
<ReleaseOverview release = { release } />
25
25
26
26
<ul className = ' flex list-none flex-col gap-2 p-0 text-sm' >
27
-
27
+ <li >
28
+ Read the <LinkWithArrow href = { ` https://github.com/nodejs/node/releases/tag/${version } ` } >changelog</LinkWithArrow > or <Link href = { ` /blog/release/${version } ` } >blog post</Link > for this version.
29
+ </li >
28
30
<li >
29
31
Learn more about <Link href = " /about/previous-releases" >Node.js releases</Link >, including the release schedule and LTS status.
30
32
</li >
Original file line number Diff line number Diff line change @@ -140,19 +140,10 @@ export const buildReleaseArtifacts = (
140
140
* Extracts the version from the pathname.
141
141
* It expects the version to be in the format like 'v22.0.4'.
142
142
*/
143
- export const extractVersionFromPath = ( pathname : string | undefined ) => {
144
- if ( ! pathname ) {
145
- return null ;
146
- }
147
-
143
+ export const extractVersionFromPath = ( pathname : string ) => {
148
144
const segments = pathname . split ( '/' ) . filter ( Boolean ) ;
149
- const version = segments . pop ( ) ;
150
-
151
- // Checks the version prefix + digits + optional dot-separated digits
152
- // (v22, v22.0.4)
153
- if ( ! version || ! version . match ( / ^ v \d + ( \. \d + ) * $ / ) ) {
154
- return null ;
155
- }
145
+ // The version is expected to be the last segment in the path
146
+ const version = segments . pop ( ) ! ;
156
147
157
148
return version ;
158
149
} ;
You can’t perform that action at this time.
0 commit comments