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) {