Skip to content

Commit 94d2054

Browse files
i529015wraithgar
authored andcommitted
fix: x-range build metadata support
1 parent 8f05c87 commit 94d2054

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

classes/range.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ const isSatisfiable = (comparators, options) => {
255255
// already replaced the hyphen ranges
256256
// turn into a set of JUST comparators.
257257
const parseComparator = (comp, options) => {
258+
comp = comp.replace(re[t.BUILD], '')
258259
debug('comp', comp, options)
259260
comp = replaceCarets(comp, options)
260261
debug('caret', comp)

test/fixtures/range-parse.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,32 @@ module.exports = [
8888
[`^${MAX_SAFE_INTEGER}.0.0`, null],
8989
[`=${MAX_SAFE_INTEGER}.0.0`, `${MAX_SAFE_INTEGER}.0.0`],
9090
[`^${MAX_SAFE_INTEGER - 1}.0.0`, `>=${MAX_SAFE_INTEGER - 1}.0.0 <${MAX_SAFE_INTEGER}.0.0-0`],
91+
// x-ranges with build metadata
92+
['1.x.x+build >2.x+build', '>=1.0.0 <2.0.0-0 >=3.0.0', null],
93+
['>=1.x+build <2.x.x+build', '>=1.0.0 <2.0.0-0', null],
94+
['1.x.x+build || 2.x.x+build', '>=1.0.0 <2.0.0-0||>=2.0.0 <3.0.0-0', null],
95+
['1.x+build.123', '>=1.0.0 <2.0.0-0', null],
96+
['1.x.x+meta-data', '>=1.0.0 <2.0.0-0', null],
97+
['1.x.x+build.123 >2.x.x+meta-data', '>=1.0.0 <2.0.0-0 >=3.0.0', null],
98+
['1.x.x+build <2.x.x+meta', '>=1.0.0 <2.0.0-0', null],
99+
['>1.x+build <=2.x.x+meta', '>=2.0.0 <3.0.0-0', null],
100+
[' 1.x.x+build >2.x.x+build ', '>=1.0.0 <2.0.0-0 >=3.0.0', null],
101+
['^1.x+build', '>=1.0.0 <2.0.0-0', null],
102+
['^1.x.x+build', '>=1.0.0 <2.0.0-0', null],
103+
['^1.2.x+build', '>=1.2.0 <2.0.0-0', null],
104+
['^1.x+meta-data', '>=1.0.0 <2.0.0-0', null],
105+
['^1.x.x+build.123', '>=1.0.0 <2.0.0-0', null],
106+
['~1.x+build', '>=1.0.0 <2.0.0-0', null],
107+
['~1.x.x+build', '>=1.0.0 <2.0.0-0', null],
108+
['~1.2.x+build', '>=1.2.0 <1.3.0-0', null],
109+
['~1.x+meta-data', '>=1.0.0 <2.0.0-0', null],
110+
['~1.x.x+build.123', '>=1.0.0 <2.0.0-0', null],
111+
['^1.x.x+build || ~2.x.x+meta', '>=1.0.0 <2.0.0-0||>=2.0.0 <3.0.0-0', null],
112+
['~1.x.x+build >2.x+meta', '>=1.0.0 <2.0.0-0 >=3.0.0', null],
113+
['^1.x+build.123 <2.x.x+meta-data', '>=1.0.0 <2.0.0-0', null],
114+
// // x-ranges with prerelease and build
115+
['1.x.x-alpha+build', '>=1.0.0 <2.0.0-0', null],
116+
['>1.x.x-alpha+build', '>=2.0.0', null],
117+
['>=1.x.x-alpha+build <2.x.x+build', '>=1.0.0 <2.0.0-0', null],
118+
['1.x.x-alpha+build || 2.x.x+build', '>=1.0.0 <2.0.0-0||>=2.0.0 <3.0.0-0', null],
91119
]

0 commit comments

Comments
 (0)