From cc6fde2d34b95cb600d126649d926901bd2a9703 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Fri, 7 Jul 2023 10:04:43 -0700 Subject: [PATCH] fix: trim each range set before parsing Fixes #587 --- classes/range.js | 2 +- test/fixtures/range-exclude.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/range.js b/classes/range.js index a7d37203..7e7c4141 100644 --- a/classes/range.js +++ b/classes/range.js @@ -38,7 +38,7 @@ class Range { this.set = this.raw .split('||') // map the range to a 2d array of comparators - .map(r => this.parseRange(r)) + .map(r => this.parseRange(r.trim())) // throw out any comparator lists that are empty // this generally means that it was not a valid range, which is allowed // in loose mode, but will still throw if the WHOLE range is invalid. diff --git a/test/fixtures/range-exclude.js b/test/fixtures/range-exclude.js index 4b6c5631..2789148a 100644 --- a/test/fixtures/range-exclude.js +++ b/test/fixtures/range-exclude.js @@ -102,4 +102,6 @@ module.exports = [ ['>=1.0.0 <1.1.0', '1.1.0', { includePrerelease: true }], ['>=1.0.0 <1.1.0', '1.1.0-pre'], ['>=1.0.0 <1.1.0-pre', '1.1.0-pre'], + + ['== 1.0.0 || foo', '2.0.0', { loose: true }], ]