diff --git a/ranges/subset.js b/ranges/subset.js index a9498323..45efaeab 100644 --- a/ranges/subset.js +++ b/ranges/subset.js @@ -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 } diff --git a/test/ranges/subset.js b/test/ranges/subset.js index c6de3570..a0781be1 100644 --- a/test/ranges/subset.js +++ b/test/ranges/subset.js @@ -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],