Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ranges/subset.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,15 @@ const simpleSubset = (sub, dom, options) => {

// will iterate one or zero times
for (const eq of eqSet) {
if (gt && !satisfies(eq, String(gt), options)) {
// test the eq version against the raw bound comparator; going through
// satisfies() rebuilds a full Range and re-applies prerelease gating, which
// wrongly rejects a prerelease eq against a plain bound of another tuple
// (the same fix PR #867 applied to the dom-side checks below)
if (gt && !gt.test(eq)) {
return null
}

if (lt && !satisfies(eq, String(lt), options)) {
if (lt && !lt.test(eq)) {
return null
}

Expand Down
5 changes: 5 additions & 0 deletions test/ranges/subset.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const cases = [
['1.2.3', '>1.2.0', true],
['1.2.3 2.3.4 || 2.3.4', '3', false],
['^1.2.3-pre.0', '1.x', false],
// a prerelease `=` comparator combined with a bound of a different tuple must
// not be treated as a null set (subset false-positive): 1.1.2-alpha is in sub
// but not in dom, so sub is not a subset of dom
['=1.1.2-alpha <3.1.0', '<1.0.0', false],
['<3.1.0-0 1.1.2-alpha', '~2.0', false],
['^1.2.3-pre.0', '1.x', true, { includePrerelease: true }],
['>2 <1', '3', true],
['1 || 2 || 3', '>=1.0.0', true],
Expand Down