From daab053561b90ba3ad104a12b38e531c60170d53 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 8 Oct 2018 19:11:40 -0600 Subject: [PATCH] correctly parse '~> 2.0.0' --- package.json | 2 +- semver-utils.js | 2 +- test/spec.js | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b598ef9..25b6558 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver-utils", - "version": "1.1.2", + "version": "1.1.3", "description": "Tools for manipulating semver strings and objects", "homepage": "https://git.coolaj86.com/coolaj86/semver-utils.js", "main": "semver-utils.js", diff --git a/semver-utils.js b/semver-utils.js index 4307a12..e7a3a1f 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 diff --git a/test/spec.js b/test/spec.js index 4017b11..e40860e 100644 --- a/test/spec.js +++ b/test/spec.js @@ -189,4 +189,14 @@ describe('parseRange', function() { }]); }); -}); \ No newline at end of file + it('should parse ~> ranges', function() { + deepOwnEqual(semverutils.parseRange('~> 2.0.0'), [{ + semver: '~> 2.0.0', + operator: '~>', + major: '2', + minor: '0', + patch: '0' + }]); + }); + +});