From db3a748f52049383a89ad5426fd9529331878645 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sat, 28 Nov 2026 08:33:21 +0900 Subject: [PATCH 1/2] Match version prefixes only at component boundaries A partial version such as mswin-3.4.1 resolved to 3.4.13 and jruby-9.4.1 to 9.4.16.0, because any version starting with the input string was accepted. Require the prefix to end between components, so these fail as unknown or pick 9.4.1.0. Co-Authored-By: Claude Opus 5.5 --- dist/index.js | 6 ++++-- index.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 861504a2d..acd191b10 100644 --- a/dist/index.js +++ b/dist/index.js @@ -88395,11 +88395,13 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe let version = parsedVersion if (!engineVersions.includes(parsedVersion)) { const latestToFirstVersion = engineVersions.slice().reverse() + // A prefix must end between version components, so 3.4.1 does not match 3.4.13 + const matches = v => v.startsWith(parsedVersion) && !(/\d$/.test(parsedVersion) && /^\d/.test(v.slice(parsedVersion.length))) // Try to match stable versions first, so an empty version (engine-only) matches the latest stable version - let found = latestToFirstVersion.find(v => common.isStableVersion(engine, v) && v.startsWith(parsedVersion)) + let found = latestToFirstVersion.find(v => common.isStableVersion(engine, v) && matches(v)) if (!found) { // Exclude head versions, they must be exact matches - found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && v.startsWith(parsedVersion)) + found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && matches(v)) } if (found) { diff --git a/index.js b/index.js index 9f2739298..6d3c8fe4c 100644 --- a/index.js +++ b/index.js @@ -172,11 +172,13 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe let version = parsedVersion if (!engineVersions.includes(parsedVersion)) { const latestToFirstVersion = engineVersions.slice().reverse() + // A prefix must end between version components, so 3.4.1 does not match 3.4.13 + const matches = v => v.startsWith(parsedVersion) && !(/\d$/.test(parsedVersion) && /^\d/.test(v.slice(parsedVersion.length))) // Try to match stable versions first, so an empty version (engine-only) matches the latest stable version - let found = latestToFirstVersion.find(v => common.isStableVersion(engine, v) && v.startsWith(parsedVersion)) + let found = latestToFirstVersion.find(v => common.isStableVersion(engine, v) && matches(v)) if (!found) { // Exclude head versions, they must be exact matches - found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && v.startsWith(parsedVersion)) + found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && matches(v)) } if (found) { From d177f2034c5174dff9287312c7d1d23a1f7eab91 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 28 Nov 2026 10:35:37 +0100 Subject: [PATCH 2/2] Simplify the version prefix match to whole components Require the partial version to be followed by a . or - separator instead of checking for a digit on both sides of the prefix end. A prefix ending inside a component, such as 3.0.0-preview, no longer matches. Co-Authored-By: Claude --- dist/index.js | 4 ++-- index.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index acd191b10..a507a3e1e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -88395,8 +88395,8 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe let version = parsedVersion if (!engineVersions.includes(parsedVersion)) { const latestToFirstVersion = engineVersions.slice().reverse() - // A prefix must end between version components, so 3.4.1 does not match 3.4.13 - const matches = v => v.startsWith(parsedVersion) && !(/\d$/.test(parsedVersion) && /^\d/.test(v.slice(parsedVersion.length))) + // A partial version must match whole components, so 3.4.1 does not match 3.4.13 + const matches = v => parsedVersion === '' || v.startsWith(`${parsedVersion}.`) || v.startsWith(`${parsedVersion}-`) // Try to match stable versions first, so an empty version (engine-only) matches the latest stable version let found = latestToFirstVersion.find(v => common.isStableVersion(engine, v) && matches(v)) if (!found) { diff --git a/index.js b/index.js index 6d3c8fe4c..c3c2bc653 100644 --- a/index.js +++ b/index.js @@ -172,8 +172,8 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe let version = parsedVersion if (!engineVersions.includes(parsedVersion)) { const latestToFirstVersion = engineVersions.slice().reverse() - // A prefix must end between version components, so 3.4.1 does not match 3.4.13 - const matches = v => v.startsWith(parsedVersion) && !(/\d$/.test(parsedVersion) && /^\d/.test(v.slice(parsedVersion.length))) + // A partial version must match whole components, so 3.4.1 does not match 3.4.13 + const matches = v => parsedVersion === '' || v.startsWith(`${parsedVersion}.`) || v.startsWith(`${parsedVersion}-`) // Try to match stable versions first, so an empty version (engine-only) matches the latest stable version let found = latestToFirstVersion.find(v => common.isStableVersion(engine, v) && matches(v)) if (!found) {