Fix reSemverRange to parse pre-release versions that contain hyphens.
This commit is contained in:
parent
ff978dc8ad
commit
86ea225075
|
@ -8,7 +8,7 @@
|
|||
// | | | |optional build prefixed by '+'
|
||||
var reSemver = /^v?((\d+)\.(\d+)\.(\d+))(?:-([\dA-Za-z\-]+(?:\.[\dA-Za-z\-]+)*))?(?:\+([\dA-Za-z\-]+(?:\.[\dA-Za-z\-]+)*))?$/
|
||||
//, reSemverRange = /\s*((\|\||\-)|(([<>~]?=?)\s*(v)?([0-9]+)(\.(x|[0-9]+))?(\.(x|[0-9]+))?(([\-+])([a-zA-Z0-9\.]+))?))\s*/g
|
||||
, reSemverRange = /\s*((\|\||\-)|(([<>~^]?=?)\s*(v)?([0-9]+)(\.(x|\*|[0-9]+))?(\.(x|\*|[0-9]+))?(([\-+])([a-zA-Z0-9\.]+))?))\s*/g
|
||||
, reSemverRange = /\s*((\|\||\-)|(([<>~^]?=?)\s*(v)?([0-9]+)(\.(x|\*|[0-9]+))?(\.(x|\*|[0-9]+))?(([\-+])([a-zA-Z0-9\.-]+))?))\s*/g
|
||||
;
|
||||
|
||||
// Returns a new object with all of the undefined properties removed from the given object
|
||||
|
|
21
test/spec.js
21
test/spec.js
|
@ -136,6 +136,27 @@ describe('parseRange', function() {
|
|||
}]);
|
||||
});
|
||||
|
||||
it('should parse pre-release versions', function() {
|
||||
deepOwnEqual(semverutils.parseRange('1.0.0-rc1'), [{
|
||||
semver: '1.0.0-rc1',
|
||||
major: '1',
|
||||
minor: '0',
|
||||
patch: '0',
|
||||
release: 'rc1'
|
||||
}]);
|
||||
});
|
||||
|
||||
it('should parse pre-release versions with hyphens', function() {
|
||||
|
||||
deepOwnEqual(semverutils.parseRange('1.0.0-rc-2'), [{
|
||||
semver: '1.0.0-rc-2',
|
||||
major: '1',
|
||||
minor: '0',
|
||||
patch: '0',
|
||||
release: 'rc-2'
|
||||
}]);
|
||||
});
|
||||
|
||||
it('should parse hyphen ranges', function() {
|
||||
deepOwnEqual(semverutils.parseRange('1.0.0 - 1.0.x'), [{
|
||||
semver: '1.0.0',
|
||||
|
|
Loading…
Reference in New Issue