Skip to content

Commit f8fcad1

Browse files
hsbtclaude
authored andcommitted
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 <noreply@anthropic.com>
1 parent 4756b6e commit f8fcad1

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎dist/index.js‎

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎index.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,13 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe
172172
let version = parsedVersion
173173
if (!engineVersions.includes(parsedVersion)) {
174174
const latestToFirstVersion = engineVersions.slice().reverse()
175+
// A prefix must end between version components, so 3.4.1 does not match 3.4.13
176+
const matches = v => v.startsWith(parsedVersion) && !(/\d$/.test(parsedVersion) && /^\d/.test(v.slice(parsedVersion.length)))
175177
// Try to match stable versions first, so an empty version (engine-only) matches the latest stable version
176-
let found = latestToFirstVersion.find(v => common.isStableVersion(engine, v) && v.startsWith(parsedVersion))
178+
let found = latestToFirstVersion.find(v => common.isStableVersion(engine, v) && matches(v))
177179
if (!found) {
178180
// Exclude head versions, they must be exact matches
179-
found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && v.startsWith(parsedVersion))
181+
found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && matches(v))
180182
}
181183

182184
if (found) {

0 commit comments

Comments
 (0)