17
return [Number(match[1]), Number(match[2]), Number(match[3])] as const;
18
}
20
>
/**
21
>
* Returns whether `offered` is semver-compatible with the server's
22
>
* `current` version, using caret semantics:
23
>
*
24
>
* - majors must match
25
>
* - when `major === 0`, minors must also match (because in 0.x semver,
26
>
* every minor bump is breaking)
27
>
* - the offered version MUST NOT be greater than `current` — a server that
28
>
* only knows `0.1.0` cannot pretend to speak `0.1.5`
29
>
*
30
>
* Invalid version strings return `false`.
31
>
*/
32
>
export function isCompatibleProtocolVersion(offered: string, current: string): boolean {
33
const a = tryParseSemver(offered);
34
const b = tryParseSemver(current);