Permalink
Browse files

Be slightly less strict about 0.* versions

- 0.0.1 still matches exactly
- 0.1.2 matches up to <0.2.0
- updated tests
  • Loading branch information...
1 parent 5705a97 commit d14aa3bd897fab24bdc0b2b5a70fde866697e09a @agnoster agnoster committed with isaacs Jul 24, 2013
Showing with 18 additions and 12 deletions.
  1. +10 −6 semver.js
  2. +8 −6 test/index.js
View
@@ -736,20 +736,24 @@ function replaceCaret(comp, loose) {
ret = '>=' + M + '.0.0-0 <' + (+M + 1) + '.0.0-0';
else if (isX(p))
if (M === '0') ret = '>=' + M + '.' + m + '.0-0 <' + M + '.' + (+m + 1) + '.0-0';
- // ^1.2 == >=1.2.0- <2.0.0-
else ret = '>=' + M + '.' + m + '.0-0 <' + (+M + 1) + '.0.0-0';
else if (pr) {
debug('replaceCaret pr', pr);
if (pr.charAt(0) !== '-')
pr = '-' + pr;
- if (M === '0') ret = '=' + M + '.' + m + '.' + p + pr
+ if (M === '0')
+ if (m === '0') ret = '=' + M + '.' + m + '.' + p + pr;
+ else ret = '>=' + M + '.' + m + '.' + p + pr +
+ ' <' + M + '.' + (+m + 1) + '.0-0';
else ret = '>=' + M + '.' + m + '.' + p + pr +
- ' <' + (+M + 1) + '.0.0-0';
+ ' <' + (+M + 1) + '.0.0-0';
} else
- if (M === '0') ret = '=' + M + '.' + m + '.' + p
- // ^1.2.3 == >=1.2.3-0 <2.0.0-0
+ if (M === '0')
+ if (m === '0') ret = '=' + M + '.' + m + '.' + p;
+ else ret = '>=' + M + '.' + m + '.' + p + '-0' +
+ ' <' + M + '.' + (+m + 1) + '.0-0';
else ret = '>=' + M + '.' + m + '.' + p + '-0' +
- ' <' + (+M + 1) + '.0.0-0';
+ ' <' + (+M + 1) + '.0.0-0';
debug('caret return', ret);
return ret;
View
@@ -382,14 +382,16 @@ test('\nvalid range test', function(t) {
['~> 1', '>=1.0.0-0 <2.0.0-0'],
['~1.0', '>=1.0.0-0 <1.1.0-0'],
['~ 1.0', '>=1.0.0-0 <1.1.0-0'],
- ['^1.2.3', '>=1.2.3-0 <2.0.0-0'],
+ ['^0', '>=0.0.0-0 <1.0.0-0'],
['^ 1', '>=1.0.0-0 <2.0.0-0'],
- ['^2.3', '>=2.3.0-0 <3.0.0-0'],
- ['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0-0'],
- ['^0.1.2-test', '=0.1.2-test'],
- ['^0.1.2', '=0.1.2'],
['^0.1', '>=0.1.0-0 <0.2.0-0'],
- ['^0', '>=0.0.0-0 <1.0.0-0'],
+ ['^1.0', '>=1.0.0-0 <2.0.0-0'],
+ ['^1.2', '>=1.2.0-0 <2.0.0-0'],
+ ['^0.0.1', '=0.0.1'],
+ ['^0.0.1-beta', '=0.0.1-beta'],
+ ['^0.1.2', '>=0.1.2-0 <0.2.0-0'],
+ ['^1.2.3', '>=1.2.3-0 <2.0.0-0'],
+ ['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0-0'],
['<1', '<1.0.0-0'],
['< 1', '<1.0.0-0'],
['>=1', '>=1.0.0-0'],

0 comments on commit d14aa3b

Please sign in to comment.