From b39c0212c5e1055b0fddccb3a5e9b1f6f79028cf Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Wed, 17 Jan 2024 22:54:27 +1300 Subject: [PATCH] fix: maintain major filter across channel switch (#38) --- src/routes/releases.js | 7 +++++-- src/views/releases.handlebars | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/routes/releases.js b/src/routes/releases.js index e152a4c..9f77114 100644 --- a/src/routes/releases.js +++ b/src/routes/releases.js @@ -78,13 +78,16 @@ router.get( const releases = await getReleasesOrUpdate(); const { page, limit, version } = req.query; const releasesFromChannel = releases.filter(filter); - const major = Number(version); + let major = parseInt(version, 10); + if (isNaN(major) || major < 0) { + major = null; + } const majors = releasesFromChannel.reduce((acc, val) => { acc.add(semver.major(val.version)); return acc; }, new Set()); const releasesFromMajor = releasesFromChannel.filter((release) => { - if (Number.isInteger(major) && major >= 0) { + if (major) { return semver.major(release.version) === major; } else { return true; diff --git a/src/views/releases.handlebars b/src/views/releases.handlebars index dc4160d..29320c1 100644 --- a/src/views/releases.handlebars +++ b/src/views/releases.handlebars @@ -3,19 +3,19 @@
Filter by channel