fix: align caret includePrerelease lower bounds by wayyoungboy · Pull Request #872 · npm/node-semver (original) (raw)
Summary
- keep exact caret lower bounds at the release version when
includePrereleaseis enabled - add regression fixtures for
^0.0.3and^0.2.3prerelease versions matching the existing^1.0.0behavior
Root Cause
For exact 0.x caret ranges without an explicit prerelease, replaceCaret appended -0 to the lower bound when includePrerelease was enabled. That turned ^0.0.3 into >=0.0.3-0 <0.0.4-0, allowing 0.0.3-alpha while exact 1.x caret ranges kept >=1.2.3 and rejected 1.2.3-alpha.
Test Plan
- RED: Node assert script confirmed
satisfies('0.0.3-alpha', '^0.0.3', { includePrerelease: true })returnedtruebefore the fix - GREEN: Node assert script for
0.0.3-alpha,0.2.3-alpha, and1.2.3-alphaall returningfalse nodefixture script covering range include/exclude fixtures: 121 include and 98 exclude cases- broader
noderange verification script: 1348 checks across range parsing, intersects, outside/gtr/ltr, min/max satisfying, and toComparators git diff --check HEAD^ HEAD
Fixes #557