semver 7.8.3 → 7.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/classes/range.js +9 -0
- package/package.json +1 -1
package/classes/range.js
CHANGED
|
@@ -277,6 +277,11 @@ const parseComparator = (comp, options) => {
|
|
|
277
277
|
|
|
278
278
|
const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
|
|
279
279
|
|
|
280
|
+
const invalidXRangeOrder = (M, m, p) => (
|
|
281
|
+
(isX(M) && !isX(m)) ||
|
|
282
|
+
(isX(m) && p && !isX(p))
|
|
283
|
+
)
|
|
284
|
+
|
|
280
285
|
// ~, ~> --> * (any, kinda silly)
|
|
281
286
|
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
|
|
282
287
|
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
|
|
@@ -402,6 +407,10 @@ const replaceXRange = (comp, options) => {
|
|
|
402
407
|
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
|
|
403
408
|
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
404
409
|
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
|
410
|
+
if (invalidXRangeOrder(M, m, p)) {
|
|
411
|
+
return comp
|
|
412
|
+
}
|
|
413
|
+
|
|
405
414
|
const xM = isX(M)
|
|
406
415
|
const xm = xM || isX(m)
|
|
407
416
|
const xp = xm || isX(p)
|