Skip to content

fix: preserve prerelease matches when simplifying ranges - #915

Draft
vhinayindia wants to merge 1 commit into
npm:mainfrom
vhinayindia:fix-simplify-prerelease-membership-20261006
Draft

vhinayindia wants to merge 1 commit into
npm:mainfrom
vhinayindia:fix-simplify-prerelease-membership-20261006

Conversation

@vhinayindia

Copy link
Copy Markdown

simplifyRange can drop matching prerelease versions when it replaces a range with shorter bounds. For example:

const versions = ['1.0.0-alpha', '1.0.0-beta', '1.0.0']
semver.simplifyRange(versions, '>=1.0.0-alpha <2.0.0') // '*'

The original range matches all three versions, but * excludes the two prereleases. One-sided bounds and hyphen ranges can lose prerelease matches in the same way because prerelease eligibility depends on comparator tuples.

Before returning a shorter range, check that it preserves membership for the supplied prerelease versions. Keep the original range if membership changes. Valid simplifications, including those using includePrerelease, still work.

Regression tests cover wildcard, upper-bound, lower-bound, and hyphen candidates; string and Range inputs; and cases where prerelease membership is unchanged.

Validation: npm test passes, including 100% coverage, ESLint, and template-oss-check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant