Closed
Description
What / Why
I've run into an interesting issue when submitting a PR for npm's arborist library, where a range (e.g. ~3.5.0
) is not a subset of any. This should be supported, as even though any is not a subset of a range (which is already handled), the opposite is not the case.
I think the fix would be to add an additional short-circuit check in lines 58-62 (v7.3.4 snippet) to handle an any dom
value:
if (sub === dom)
return true
+ if (dom.length === 1 && dom[0].semver === ANY)
+ return true
if (sub.length === 1 && sub[0].semver === ANY)
return dom.length === 1 && dom[0].semver === ANY
When
I run a subset comparison for if a given range is a subset of any
Example
const semver = require("semver");
// ~3.5.0 := >=3.5.0 <3.(5+1).0 := >=3.5.0 <3.6.0-0
console.log(semver.subset("~3.5.0", "*"));
// false
Current Behavior
Result is falsey.
Expected Behavior
Result should be truthy, as >=3.5.0 <3.6.0-0
should be a subset of any.
References
Metadata
Metadata
Assignees
Labels
No labels