Skip to content

Commit

Permalink
semver fix
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Nov 14, 2014
1 parent 7a25d33 commit 041abf0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/semver.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ function matchParsed(range, version) {

// if the version has a prerelease, ensure the range version has a prerelease in it
// and that we match the range version up to the prerelease exactly
if (version.pre)
return !!(rangeVersion.pre && rangeVersion.major == version.major && rangeVersion.minor == version.minor && rangeVersion.patch == version.patch);
if (version.pre) {
if (!(rangeVersion.major == version.major && rangeVersion.minor == version.minor && rangeVersion.patch == version.patch))
return false;
return range.semver || range.fuzzy || rangeVersion.pre.join('.') == version.pre.join('.');
}

// check semver range
if (range.semver) {
Expand All @@ -142,7 +145,7 @@ function matchParsed(range, version) {

// exact match
// eg 001.002.003 matches 1.2.3
return !!(!rangeVersion.pre && rangeVersion.major == version.major && rangeVersion.minor == version.minor && rangeVersion.patch == version.patch);
return !rangeVersion.pre && rangeVersion.major == version.major && rangeVersion.minor == version.minor && rangeVersion.patch == version.patch;
}

/*
Expand Down
1 change: 1 addition & 0 deletions test/semver.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ suite('Semver Compatibility Ranges', function() {
// project.showLogs = true;
// assert.equal(semver.match('^1.5.2', '1.4.0'), false);
assert.equal(semver.match('^1', '1.4.0'), true);
assert.equal(semver.match('1.0.0-beta.13', '1.0.0-beta.5b'), false);
});

test('Semver compatibility', function() {
Expand Down

0 comments on commit 041abf0

Please sign in to comment.