[BUG] subset() returns false for an upper-bound-only range such as subset('<2.0.0', '*')

Abierto
#949 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
74/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript, node.js
Área
backend

Línea de trabajo

Start in ranges/subset.js at simpleSubset, especially the lt && hasDomGT && !gt condition described in the issue. Trace how missing lower bounds and * are normalized, then check the existing subset tests for these range combinations. Done means the first five reproductions return true while existing subset behavior remains correct.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Is there an existing issue for this?
  • I have searched the existing issues
Current Behavior

subset(sub, dom) returns false when sub has only an upper bound (< or <=) and dom has a lower bound, including *, which subset treats as >=0.0.0. Every version that satisfies <2.0.0 also satisfies *, so the README's "entirely contained" definition gives true.

subset('<1.0.0', '0.x') is a related false negative: 0.x is >=0.0.0 <1.0.0-0, which admits the same non-prerelease versions as <1.0.0.

Expected Behavior

The first five lines below print true.

In ranges/subset.js, simpleSubset replaces * in dom with >=0.0.0 and then returns false for lt && hasDomGT && !gt, which treats a missing lower bound in sub as unbounded below instead of >=0.0.0.

Steps To Reproduce
const { subset } = require('semver')
console.log(subset('<2.0.0', '*'))
console.log(subset('<2', '*'))
console.log(subset('<2.0.0', '>=0.0.0'))
console.log(subset('<2.0.0', '>=0.0.0-0'))
console.log(subset('<1.0.0', '0.x'))
console.log(subset('<1.0.0', '>=0.0.0 <1.0.0'))
console.log(subset('^1.2.3', '*'))

Output:

false
false
false
false
false
true
true
Environment
  • semver: 7.8.6, also main at b37b033
  • Node: 26.13.0
  • OS: Ubuntu Linux
  • platform: x86_64

Credit: https://ucsbplse.github.io/

Lenguaje dominante
JavaScript
Estrellas
5.5k
Forks
624
Merge medio
6 d 1 h
PR fusionados (30 d)
13

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de npm/node-semver

Todos los issues de npm/node-semver

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.