diff --git a/semver-utils.js b/semver-utils.js index 994239f..4307a12 100644 --- a/semver-utils.js +++ b/semver-utils.js @@ -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 @@ -54,7 +54,7 @@ } arr.forEach(stringify); - + return str.trim(); } @@ -107,11 +107,11 @@ , build: m[6] })) ; - + if (0 === m.length) { ver = null; } - + return ver; } @@ -120,7 +120,7 @@ , arr = [] , obj ; - + while (m = reSemverRange.exec(str)) { obj = { @@ -139,7 +139,7 @@ arr.push(new SemVer(pruned(obj))); //console.log(m); } - + //return new SemVerRange(arr); return arr; } diff --git a/test/spec.js b/test/spec.js index 0417f17..4017b11 100644 --- a/test/spec.js +++ b/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',