Skip to content

Commit

Permalink
fix: trim each range set before parsing
Browse files Browse the repository at this point in the history
Fixes npm#587
  • Loading branch information
lukekarrys committed Jul 7, 2023
1 parent 99d8287 commit cc6fde2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion classes/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/range-exclude.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }],
]

0 comments on commit cc6fde2

Please sign in to comment.