Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[BUG] `* || 1.2.3-alpha` won't match `1.2.3-alpha` (when includePrerelease = false)

Aperta
#906 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@x0Lazarus ci sta già lavorando.

Dal 26/9/2026.

  • #907 di @x0Lazarus — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, nodejs
Ambito
tooling

Direzione di ricerca

Start in classes/range.js at the Range constructor, then read the README's range and prerelease rules alongside the linked discussion in #183. Reproduce the four satisfies calls and inspect the resulting Range.range value; done means the explicit prerelease alternative still matches when combined with a wildcard while the wildcard alone does not admit it.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

With [email protected] and the default options:

const semver = require('semver')

semver.satisfies('1.2.3-alpha', '1.2.3-alpha')      // true
semver.satisfies('1.2.3-alpha', '*')                // false
semver.satisfies('1.2.3-alpha', '* || 1.2.3-alpha') // false
semver.satisfies('1.2.3-alpha', '1.2.3-alpha || *') // false

new semver.Range('* || 1.2.3-alpha').range // ''

The explicit prerelease alternative matches on its own, but adding * || makes it stop matching. The same result occurs with the alternatives reversed. This is reproducible from the unmodified v7.8.5 tag (Node v22.23.3).

The range constructor collapses the whole OR range to * when any alternative is a wildcard, before prerelease eligibility is checked. This discards the explicit prerelease alternative and changes the set of matching versions.

Expected Behavior

The README's range description says a range matches when at least one ||-separated comparator set matches, and its prerelease rule checks for an eligible comparator within a comparator set. Thus 1.2.3-alpha should match the explicit 1.2.3-alpha alternative even though the wildcard alternative does not admit prereleases. In #183, @isaacs explicitly noted that * || 1.0.0-prerelease is different from * for this reason.

The Range.constructor shouldn't collapse * || 1.2.3-alpha into just *, when includePrerelease is false and one of the other comparators has a prerelease version.

Steps To Reproduce

n/a

Environment

n/a

Lingua principale
JavaScript
Stelle
5.5k
Fork
617
Merge medio
4g 23h
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di npm/node-semver

Tutte le issue di npm/node-semver

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.