diff --git a/src/utils/semver.ts b/src/utils/semver.ts index d4386477..6c3b5f37 100644 --- a/src/utils/semver.ts +++ b/src/utils/semver.ts @@ -183,7 +183,7 @@ export class Range { return this.set.map(v => { if (!isArray(v)) return `=${v.toString()}` const [v1, v2] = v - if (v2.major == v1.major + 1 && v2.minor == 0 && v2.patch == 0) { + if (v1.major > 0 && v2.major == v1.major + 1 && v2.minor == 0 && v2.patch == 0) { const v = chomp(v1) return `^${v}` } else if (v2.major == v1.major && v2.minor == v1.minor + 1 && v2.patch == 0) { diff --git a/tests/unit/semver.test.ts b/tests/unit/semver.test.ts index dd941cdf..abd87e81 100644 --- a/tests/unit/semver.test.ts +++ b/tests/unit/semver.test.ts @@ -191,6 +191,16 @@ Deno.test("semver", async test => { assert(b.satisfies(new SemVer("12.9.0"))) }) + await test.step(">=0.47<1", () => { + const a = new semver.Range(">=0.47<1") + assertEquals(a.toString(), ">=0.47<1") + assert(a.satisfies(new SemVer("0.47.0"))) + assert(a.satisfies(new SemVer("0.47.9"))) + assert(a.satisfies(new SemVer("0.48.0"))) + assert(a.satisfies(new SemVer("0.80.0"))) + assertFalse(a.satisfies(new SemVer("1.0.0"))) + }) + //FIXME this *should* work // await test.step("^11,^12…^11.3,^12.2", () => { // const a = new semver.Range("^11,^12")