Skip to content

Commit

Permalink
Merge b423ce1 into 6086e5a
Browse files Browse the repository at this point in the history
  • Loading branch information
Asthetic committed Mar 9, 2019
2 parents 6086e5a + b423ce1 commit b57d790
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
5 changes: 3 additions & 2 deletions semver.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ Comparator.prototype.parse = function (comp) {

if (!m) { throw new TypeError('Invalid comparator: ' + comp) }

this.operator = m[1]
this.operator = m[1] !== undefined ? m[1] : ''
if (this.operator === '=') { this.operator = '' }

// if it literally is just '>' or '' then allow anything.
Expand All @@ -654,7 +654,7 @@ Comparator.prototype.toString = function () {
Comparator.prototype.test = function (version) {
debug('Comparator.test', version, this.options.loose)

if (this.semver === ANY) { return true }
if (this.semver === ANY || version === ANY) { return true }

if (typeof version === 'string') { version = new SemVer(version, this.options) }

Expand Down Expand Up @@ -1027,6 +1027,7 @@ function hyphenReplace ($0,

// if ANY of the sets match ALL of its comparators, then pass
Range.prototype.test = function (version) {
if (version === '' || version === ANY) { return true }
if (!version) { return false }

if (typeof version === 'string') { version = new SemVer(version, this.options) }
Expand Down
40 changes: 39 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,45 @@ test('\nranges intersect', function (t) {
['<1.0.0 >2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false],
['>1.0.0 <=2.0.0', '2.0.0', true],
['<1.0.0 >=2.0.0', '2.1.0', false],
['<1.0.0 >=2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false]
['<1.0.0 >=2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false],
['*', '0.0.1', true],
['*', '>=1.0.0', true],
['*', '>1.0.0', true],
['*', '~1.0.0', true],
['*', '<1.6.0', true],
['*', '<=1.6.0', true],
['1.*', '0.0.1', false],
['1.*', '2.0.0', false],
['1.*', '1.0.0', true],
['1.*', '<2.0.0', true],
['1.*', '>1.0.0', true],
['1.*', '<=1.0.0', true],
['1.*', '^1.0.0', true],
['1.0.*', '0.0.1', false],
['1.0.*', '<0.0.1', false],
['1.0.*', '>0.0.1', true],
['*', '1.3.0 || <1.0.0 >2.0.0', true],
['1.3.0 || <1.0.0 >2.0.0', '*', true],
['1.*', '1.3.0 || <1.0.0 >2.0.0', true],
['x', '0.0.1', true],
['x', '>=1.0.0', true],
['x', '>1.0.0', true],
['x', '~1.0.0', true],
['x', '<1.6.0', true],
['x', '<=1.6.0', true],
['1.x', '0.0.1', false],
['1.x', '2.0.0', false],
['1.x', '1.0.0', true],
['1.x', '<2.0.0', true],
['1.x', '>1.0.0', true],
['1.x', '<=1.0.0', true],
['1.x', '^1.0.0', true],
['1.0.x', '0.0.1', false],
['1.0.x', '<0.0.1', false],
['1.0.x', '>0.0.1', true],
['x', '1.3.0 || <1.0.0 >2.0.0', true],
['1.3.0 || <1.0.0 >2.0.0', 'x', true],
['1.x', '1.3.0 || <1.0.0 >2.0.0', true]
].forEach(function (v) {
var range1 = new Range(v[0])
var range2 = new Range(v[1])
Expand Down

0 comments on commit b57d790

Please sign in to comment.