Skip to content

[BUG] Test case in fixture for inclusion includes case that is outside of the range #799

@schellingerhout

Description

@schellingerhout

Per the README

If a partial version is provided as the second version in the
inclusive range, then all versions that start with the supplied parts
of the tuple are accepted, but nothing that would be greater than the
provided tuple parts.

  • 1.2.3 - 2.3 := >=1.2.3 <2.4.0-0
  • 1.2.3 - 2 := >=1.2.3 <3.0.0-0

That implies that 1 - 2 := >=1.0.0 <3.0.0-0 (at or above any release of 1 but below the lowest possible pre-release of 3). It is not >=1.0.0-0 <3.0.0-0

There is an inclusion test in test/fixtures/range-include.js
['1 - 2', '1.0.0-pre', { includePrerelease: true }]

1.0.0-pre is ordered before 1.0.0 per the Semver.org spec and therefore not included in the range. The fact that includePrerelease is true should not expand the range, but only drop the requirement that "at least one comparator with the same [major, minor, patch] tuple also has a prerelease tag" and "[treat] all prerelease versions as if they were normal versions for range-matching".

The only reason this case would pass if includePrerelease changed the range to >=1.0.0-0 <3.0.0-0, but is not what the README specifies. For consistency only matching should be affected by the setting, not the ranges against which matching is made.

EDIT: There are some ambiguities in the README "all versions that start with the supplied parts of the tuple are accepted" seem to apply pattern matching in which case that would explain the matching to a pre-release, but then it also states "but nothing that would be greater than the provided tuple parts". The use of "greater" is confusing and odd in this context since we can clearly match larger than the lower bound, I assume it should have read "smaller than the lower bound or greater than the upper bound provided tuple parts". In that case we are back to the interpretation that the pre-release is out of the bounds and therefore should not match regardless of includePrerelease

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions