fix: fix range regexp to handle version with multiple digits
This commit is contained in:
		
							parent
							
								
									89663d3fcf
								
							
						
					
					
						commit
						9a04e64fab
					
				| @ -31,11 +31,11 @@ function isMaintenanceRange(range) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getUpperBound(range) { | function getUpperBound(range) { | ||||||
|   return semver.valid(range) ? range : ((semver.validRange(range) || '').match(/<(\d\.\d\.\d)$/) || [])[1]; |   return semver.valid(range) ? range : ((semver.validRange(range) || '').match(/<(\d+\.\d+\.\d+)$/) || [])[1]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getLowerBound(range) { | function getLowerBound(range) { | ||||||
|   return ((semver.validRange(range) || '').match(/(\d\.\d\.\d)/) || [])[1]; |   return ((semver.validRange(range) || '').match(/(\d+\.\d+\.\d+)/) || [])[1]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function highest(version1, version2) { | function highest(version1, version2) { | ||||||
|  | |||||||
| @ -70,18 +70,30 @@ test('isMaintenanceRange', t => { | |||||||
| 
 | 
 | ||||||
| test('getUpperBound', t => { | test('getUpperBound', t => { | ||||||
|   t.is(getUpperBound('1.x.x'), '2.0.0'); |   t.is(getUpperBound('1.x.x'), '2.0.0'); | ||||||
|  |   t.is(getUpperBound('1.X.X'), '2.0.0'); | ||||||
|  |   t.is(getUpperBound('10.x.x'), '11.0.0'); | ||||||
|   t.is(getUpperBound('1.x'), '2.0.0'); |   t.is(getUpperBound('1.x'), '2.0.0'); | ||||||
|  |   t.is(getUpperBound('10.x'), '11.0.0'); | ||||||
|   t.is(getUpperBound('1.0.x'), '1.1.0'); |   t.is(getUpperBound('1.0.x'), '1.1.0'); | ||||||
|  |   t.is(getUpperBound('10.0.x'), '10.1.0'); | ||||||
|  |   t.is(getUpperBound('10.10.x'), '10.11.0'); | ||||||
|   t.is(getUpperBound('1.0.0'), '1.0.0'); |   t.is(getUpperBound('1.0.0'), '1.0.0'); | ||||||
|  |   t.is(getUpperBound('10.0.0'), '10.0.0'); | ||||||
| 
 | 
 | ||||||
|   t.is(getUpperBound('foo'), undefined); |   t.is(getUpperBound('foo'), undefined); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('getLowerBound', t => { | test('getLowerBound', t => { | ||||||
|   t.is(getLowerBound('1.x.x'), '1.0.0'); |   t.is(getLowerBound('1.x.x'), '1.0.0'); | ||||||
|  |   t.is(getLowerBound('1.X.X'), '1.0.0'); | ||||||
|  |   t.is(getLowerBound('10.x.x'), '10.0.0'); | ||||||
|   t.is(getLowerBound('1.x'), '1.0.0'); |   t.is(getLowerBound('1.x'), '1.0.0'); | ||||||
|  |   t.is(getLowerBound('10.x'), '10.0.0'); | ||||||
|   t.is(getLowerBound('1.0.x'), '1.0.0'); |   t.is(getLowerBound('1.0.x'), '1.0.0'); | ||||||
|  |   t.is(getLowerBound('10.0.x'), '10.0.0'); | ||||||
|  |   t.is(getLowerBound('1.10.x'), '1.10.0'); | ||||||
|   t.is(getLowerBound('1.0.0'), '1.0.0'); |   t.is(getLowerBound('1.0.0'), '1.0.0'); | ||||||
|  |   t.is(getLowerBound('10.0.0'), '10.0.0'); | ||||||
| 
 | 
 | ||||||
|   t.is(getLowerBound('foo'), undefined); |   t.is(getLowerBound('foo'), undefined); | ||||||
| }); | }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user