# SemVer range tester

Test versions against an npm-style range such as ^1.2.3 or >=1.0 <2 and find the highest match.

- Endpoint: `POST https://setget.net/v1/tools/semver-range` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `semver-range`
- Page: https://setget.net/tools/semver-range

## Inputs

- `range` (required, string): The range, in npm syntax: ^, ~, x-ranges, hyphen ranges, comparators and ||.
- `versions` (required, array): The versions to test.
- `include_prerelease` (optional, boolean, default `false`): Let prerelease versions match like ordinary versions.

## Example 1

```json
{"input":{"range":"^1.2.3","versions":["1.2.2","1.2.3","1.9.0","2.0.0","1.3.0-beta.1"]}}
```

Result:

```json
{"range":"^1.2.3","normalised":">=1.2.3 <2.0.0-0","matching":["1.2.3","1.9.0"],"not_matching":["1.2.2","2.0.0","1.3.0-beta.1"],"invalid":[],"highest":"1.9.0"}
```

## Example 2: Tilde, hyphen range and "or"

```json
{"input":{"range":"~1.2 || 2.0.0 - 2.5","versions":["1.2.9","1.3.0","2.5.7","2.6.0"]}}
```

Result:

```json
{"range":"~1.2 || 2.0.0 - 2.5","normalised":">=1.2.0 <1.3.0-0 || >=2.0.0 <2.6.0-0","matching":["1.2.9","2.5.7"],"not_matching":["1.3.0","2.6.0"],"invalid":[],"highest":"2.5.7"}
```

**What is the difference between ^ and ~?** ^1.2.3 allows changes that keep the first non-zero number (up to, not including, 2.0.0). ~1.2.3 allows only patch updates (below 1.3.0).

**Why does a prerelease not match?** As in npm, 1.3.0-beta.1 matches only if the range itself names a prerelease of 1.3.0. Turn on include_prerelease to change that.

**What does "<2.0.0-0" mean?** Below every 2.0.0 version, including its prereleases. It is how npm writes an exclusive upper bound.
