Skip to content

Commit 76b0908

Browse files
CodingRuleWai.Tungovflowdmikeesto
authored
Update getNodeJsChangelog.ts (#5267)
Co-authored-by: SpriteyOnTheDraconic <91148727+SpriteyOnTheDraconic@users.noreply.github.com> Co-authored-by: Wai.Tung <maledong_public@foxmail.com> Co-authored-by: Claudio Wunder <cwunder@gnome.org> Co-authored-by: Michael Esteban <mickel13@gmail.com>
1 parent df344bd commit 76b0908

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

util/getNodeJsChangelog.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
import semVer from 'semver';
22

3-
export const getNodejsChangelog = (version: string) => {
4-
const changelogs = 'https://github.com/nodejs/node/blob/main/doc/changelogs';
3+
/**
4+
* Returns the URL of the Node.js changelog for the specified version.
5+
*
6+
* @param version The version of Node.js to get the changelog for.
7+
* @returns The URL of the Node.js changelog for the specified version.
8+
*/
9+
export const getNodejsChangelog = (version: string): string => {
10+
const changelogsUrl =
11+
'https://github.com/nodejs/node/blob/main/doc/changelogs';
512

6-
const clean = semVer.clean(version);
13+
// Parse the version string and get the major and minor versions
14+
const cleanVersion = semVer.clean(version);
15+
const majorVersion = semVer.major(cleanVersion!);
16+
const minorVersion = semVer.minor(cleanVersion!);
717

8-
const major = semVer.major(clean!);
9-
const minor = semVer.minor(clean!);
10-
11-
if (major >= 4) {
12-
return `${changelogs}/CHANGELOG_V${major}.md#${clean}`;
18+
// Determine the URL of the changelog based on the version
19+
if (majorVersion >= 4) {
20+
return `${changelogsUrl}/CHANGELOG_V${majorVersion}.md#${cleanVersion}`;
1321
}
1422

15-
if (major >= 1) {
16-
return `${changelogs}/CHANGELOG_IOJS.md#${clean}`;
23+
if (majorVersion >= 1) {
24+
return `${changelogsUrl}/CHANGELOG_IOJS.md#${cleanVersion}`;
1725
}
1826

19-
if (minor === 12 || minor === 10) {
20-
return `${changelogs}/CHANGELOG_V${major}${minor}.md#${clean}`;
27+
if (minorVersion === 12 || minorVersion === 10) {
28+
return `${changelogsUrl}/CHANGELOG_V${majorVersion}${minorVersion}.md#${cleanVersion}`;
2129
}
2230

2331
return `https://github.com/nodejs/node-v0.x-archive/blob/${version}/ChangeLog`;

0 commit comments

Comments
 (0)