Skip to content

Commit

Permalink
Add a -0 prerelease on >X and <X ranges
Browse files Browse the repository at this point in the history
In includePrerelease mode, there are in fact versions less than 0.0.0
which will satisfy the range <0.0.0.
  • Loading branch information
isaacs committed Jul 1, 2019
1 parent 7ba4563 commit ba19e8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion semver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1164,10 +1164,14 @@ function replaceXRange (comp, options) {
gtlt = ''
}

// if we're including prereleases in the match, then we need
// to fix this to -0, the lowest possible prerelease value
pr = options.includePrerelease ? '-0' : ''

if (xM) {
if (gtlt === '>' || gtlt === '<') {
// nothing is allowed
ret = '<0.0.0'
ret = '<0.0.0-0'
} else {
// nothing is forbidden
ret = '*'
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,8 @@ test('comparators test', function (t) {
['1.2 - 3.4.5', [['>=1.2.0', '<=3.4.5']]],
['1.2.3 - 3.4', [['>=1.2.3', '<3.5.0']]],
['1.2.3 - 3', [['>=1.2.3', '<4.0.0']]],
['>*', [['<0.0.0']]],
['<*', [['<0.0.0']]]
['>*', [['<0.0.0-0']]],
['<*', [['<0.0.0-0']]]
].forEach(function (v) {
var pre = v[0]
var wanted = v[1]
Expand Down

0 comments on commit ba19e8f

Please sign in to comment.