Skip to content

Commit 9d8d3f4

Browse files
committed
handle undefined version passed to Range.test
Fix #278 Regression in 6.1.0
1 parent 0c9dbd0 commit 9d8d3f4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

semver.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,10 @@ function hyphenReplace ($0,
12561256

12571257
// if ANY of the sets match ALL of its comparators, then pass
12581258
Range.prototype.test = function (version) {
1259+
if (!version) {
1260+
return false
1261+
}
1262+
12591263
if (typeof version === 'string') {
12601264
version = new SemVer(version, this.options)
12611265
}

test/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ test('range tests', function (t) {
248248
['x - 1.x', '0.9.7'],
249249
['1.0.0 - x', '1.9.7'],
250250
['1.x - x', '1.9.7'],
251-
['<=7.x', '7.9.9']
251+
['<=7.x', '7.9.9'],
252252
].forEach(function (v) {
253253
var range = v[0]
254254
var ver = v[1]
@@ -333,6 +333,8 @@ test('negative range tests', function (t) {
333333
['blerg', '1.2.3'],
334334
['git+https://user:[email protected]/foo', '123.0.0', true],
335335
['^1.2.3', '2.0.0-pre'],
336+
['0.x', undefined],
337+
['*', undefined],
336338
].forEach(function (v) {
337339
var range = v[0]
338340
var ver = v[1]

0 commit comments

Comments
 (0)