Skip to content

Commit ba19e8f

Browse files
committed
Add a -0 prerelease on >X and <X ranges
In includePrerelease mode, there are in fact versions less than 0.0.0 which will satisfy the range <0.0.0.
1 parent 7ba4563 commit ba19e8f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

semver.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1164,10 +1164,14 @@ function replaceXRange (comp, options) {
11641164
gtlt = ''
11651165
}
11661166

1167+
// if we're including prereleases in the match, then we need
1168+
// to fix this to -0, the lowest possible prerelease value
1169+
pr = options.includePrerelease ? '-0' : ''
1170+
11671171
if (xM) {
11681172
if (gtlt === '>' || gtlt === '<') {
11691173
// nothing is allowed
1170-
ret = '<0.0.0'
1174+
ret = '<0.0.0-0'
11711175
} else {
11721176
// nothing is forbidden
11731177
ret = '*'

test/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ test('comparators test', function (t) {
679679
['1.2 - 3.4.5', [['>=1.2.0', '<=3.4.5']]],
680680
['1.2.3 - 3.4', [['>=1.2.3', '<3.5.0']]],
681681
['1.2.3 - 3', [['>=1.2.3', '<4.0.0']]],
682-
['>*', [['<0.0.0']]],
683-
['<*', [['<0.0.0']]]
682+
['>*', [['<0.0.0-0']]],
683+
['<*', [['<0.0.0-0']]]
684684
].forEach(function (v) {
685685
var pre = v[0]
686686
var wanted = v[1]

0 commit comments

Comments
 (0)