diff --git a/classes/range.js b/classes/range.js index f80c2359..94629ce6 100644 --- a/classes/range.js +++ b/classes/range.js @@ -255,6 +255,7 @@ const isSatisfiable = (comparators, options) => { // already replaced the hyphen ranges // turn into a set of JUST comparators. const parseComparator = (comp, options) => { + comp = comp.replace(re[t.BUILD], '') debug('comp', comp, options) comp = replaceCarets(comp, options) debug('caret', comp) diff --git a/test/fixtures/range-parse.js b/test/fixtures/range-parse.js index 3fdd5ff2..e4e252d7 100644 --- a/test/fixtures/range-parse.js +++ b/test/fixtures/range-parse.js @@ -88,4 +88,32 @@ module.exports = [ [`^${MAX_SAFE_INTEGER}.0.0`, null], [`=${MAX_SAFE_INTEGER}.0.0`, `${MAX_SAFE_INTEGER}.0.0`], [`^${MAX_SAFE_INTEGER - 1}.0.0`, `>=${MAX_SAFE_INTEGER - 1}.0.0 <${MAX_SAFE_INTEGER}.0.0-0`], + // x-ranges with build metadata + ['1.x.x+build >2.x+build', '>=1.0.0 <2.0.0-0 >=3.0.0', null], + ['>=1.x+build <2.x.x+build', '>=1.0.0 <2.0.0-0', null], + ['1.x.x+build || 2.x.x+build', '>=1.0.0 <2.0.0-0||>=2.0.0 <3.0.0-0', null], + ['1.x+build.123', '>=1.0.0 <2.0.0-0', null], + ['1.x.x+meta-data', '>=1.0.0 <2.0.0-0', null], + ['1.x.x+build.123 >2.x.x+meta-data', '>=1.0.0 <2.0.0-0 >=3.0.0', null], + ['1.x.x+build <2.x.x+meta', '>=1.0.0 <2.0.0-0', null], + ['>1.x+build <=2.x.x+meta', '>=2.0.0 <3.0.0-0', null], + [' 1.x.x+build >2.x.x+build ', '>=1.0.0 <2.0.0-0 >=3.0.0', null], + ['^1.x+build', '>=1.0.0 <2.0.0-0', null], + ['^1.x.x+build', '>=1.0.0 <2.0.0-0', null], + ['^1.2.x+build', '>=1.2.0 <2.0.0-0', null], + ['^1.x+meta-data', '>=1.0.0 <2.0.0-0', null], + ['^1.x.x+build.123', '>=1.0.0 <2.0.0-0', null], + ['~1.x+build', '>=1.0.0 <2.0.0-0', null], + ['~1.x.x+build', '>=1.0.0 <2.0.0-0', null], + ['~1.2.x+build', '>=1.2.0 <1.3.0-0', null], + ['~1.x+meta-data', '>=1.0.0 <2.0.0-0', null], + ['~1.x.x+build.123', '>=1.0.0 <2.0.0-0', null], + ['^1.x.x+build || ~2.x.x+meta', '>=1.0.0 <2.0.0-0||>=2.0.0 <3.0.0-0', null], + ['~1.x.x+build >2.x+meta', '>=1.0.0 <2.0.0-0 >=3.0.0', null], + ['^1.x+build.123 <2.x.x+meta-data', '>=1.0.0 <2.0.0-0', null], + // // x-ranges with prerelease and build + ['1.x.x-alpha+build', '>=1.0.0 <2.0.0-0', null], + ['>1.x.x-alpha+build', '>=2.0.0', null], + ['>=1.x.x-alpha+build <2.x.x+build', '>=1.0.0 <2.0.0-0', null], + ['1.x.x-alpha+build || 2.x.x+build', '>=1.0.0 <2.0.0-0||>=2.0.0 <3.0.0-0', null], ]