Skip to content

Commit d177f20

Browse files
eregonclaude
andcommitted
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 <noreply@anthropic.com>
1 parent db3a748 commit d177f20

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎dist/index.js‎

Lines changed: 2 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ 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)))
175+
// A partial version must match whole components, so 3.4.1 does not match 3.4.13
176+
const matches = v => parsedVersion === '' || v.startsWith(`${parsedVersion}.`) || v.startsWith(`${parsedVersion}-`)
177177
// Try to match stable versions first, so an empty version (engine-only) matches the latest stable version
178178
let found = latestToFirstVersion.find(v => common.isStableVersion(engine, v) && matches(v))
179179
if (!found) {

0 commit comments

Comments
 (0)