Changeset 6c7cfa6 for node_modules/semver/classes/range.js
- Timestamp:
- 09/21/26 00:41:03 (9 days ago)
- Branches:
- main
- Children:
- 2d1ec46
- Parents:
- 6149556
- git-author:
- Klimentina Efremova <klimentina08642@…> (09/21/26 00:24:09)
- git-committer:
- Klimentina Efremova <klimentina08642@…> (09/21/26 00:41:03)
- File:
-
- 1 edited
-
node_modules/semver/classes/range.js (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
node_modules/semver/classes/range.js
r6149556 r6c7cfa6 99 99 100 100 parseRange (range) { 101 // strip build metadata so it can't bleed into the version 102 range = range.replace(BUILDSTRIPRE, '') 103 101 104 // memoize range parsing for performance. 102 105 // this is a very hot path, and fully deterministic. … … 224 227 const { 225 228 safeRe: re, 229 src, 226 230 t, 227 231 comparatorTrimReplace, … … 230 234 } = require('../internal/re') 231 235 const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants') 236 237 // unbounded global build-metadata stripper used by parseRange 238 const BUILDSTRIPRE = new RegExp(src[t.BUILD], 'g') 232 239 233 240 const isNullSet = c => c.value === '<0.0.0-0' … … 271 278 const isX = id => !id || id.toLowerCase() === 'x' || id === '*' 272 279 280 const invalidXRangeOrder = (M, m, p) => ( 281 (isX(M) && !isX(m)) || 282 (isX(m) && p && !isX(p)) 283 ) 284 273 285 // ~, ~> --> * (any, kinda silly) 274 286 // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0 … … 288 300 const replaceTilde = (comp, options) => { 289 301 const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] 302 // if we're including prereleases in the match, then the lower bound is 303 // -0, the lowest possible prerelease value, just like x-ranges and carets. 304 // this keeps `~1.2` equivalent to the `1.2.x` x-range it's documented as. 305 const z = options.includePrerelease ? '-0' : '' 290 306 return comp.replace(r, (_, M, m, p, pr) => { 291 307 debug('tilde', comp, _, M, m, p, pr) … … 295 311 ret = '' 296 312 } else if (isX(m)) { 297 ret = `>=${M}.0.0 <${+M + 1}.0.0-0`313 ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0` 298 314 } else if (isX(p)) { 299 315 // ~1.2 == >=1.2.0 <1.3.0-0 300 ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`316 ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0` 301 317 } else if (pr) { 302 318 debug('replaceTilde pr', pr) … … 367 383 if (m === '0') { 368 384 ret = `>=${M}.${m}.${p 369 } ${z}<${M}.${m}.${+p + 1}-0`385 } <${M}.${m}.${+p + 1}-0` 370 386 } else { 371 387 ret = `>=${M}.${m}.${p 372 } ${z}<${M}.${+m + 1}.0-0`388 } <${M}.${+m + 1}.0-0` 373 389 } 374 390 } else { … … 396 412 return comp.replace(r, (ret, gtlt, M, m, p, pr) => { 397 413 debug('xRange', comp, ret, gtlt, M, m, p, pr) 414 if (invalidXRangeOrder(M, m, p)) { 415 return comp 416 } 417 398 418 const xM = isX(M) 399 419 const xm = xM || isX(m)
Note:
See TracChangeset
for help on using the changeset viewer.
