@devries-cameron20 / t3code Mirror · read-only / commits / 1b6336d237
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 05:45 UTC

fix(shared): preserve omitted components in zero-major caret ranges (#29335)

Co-authored-by: maria-rcks <maria@kuuro.net>

Johan Vaz committed Nov 4, 2026 at 07:16 UTC 1b6336d237d7c800dd5c620d96627f2a9c71140c
2 files changed +10 -2
packages/shared/src/semver.test.ts
+8
@@ -59,12 +59,18 @@ describe("semver helpers", () => {
59 });
60
61 it("honors caret range upper bounds for zero-major versions", () => {
62 + expect(satisfiesSemverRange("0.5.0", "^0")).toBe(true);
63 + expect(satisfiesSemverRange("0.0.4", "^0.0")).toBe(true);
64 + expect(satisfiesSemverRange("1.0.0", "^0")).toBe(false);
65 + expect(satisfiesSemverRange("0.1.0", "^0.0")).toBe(false);
66 expect(satisfiesSemverRange("0.2.3", "^0.2.3")).toBe(true);
67 expect(satisfiesSemverRange("0.2.9", "^0.2.3")).toBe(true);
68 expect(satisfiesSemverRange("0.3.0", "^0.2.3")).toBe(false);
69 expect(satisfiesSemverRange("0.5.0", "^0.2.3")).toBe(false);
70 expect(satisfiesSemverRange("0.0.3", "^0.0.3")).toBe(true);
71 expect(satisfiesSemverRange("0.0.4", "^0.0.3")).toBe(false);
72 + expect(satisfiesSemverRange("0.0.0", "^0.0.0")).toBe(true);
73 + expect(satisfiesSemverRange("0.0.1", "^0.0.0")).toBe(false);
74 });
75
76 it("keeps the range checker stringifiable and executable as plain JavaScript", () => {
@@ -74,6 +80,8 @@ describe("semver helpers", () => {
80 expect(source).toContain("function satisfiesSemverRange");
81 expect(source).not.toContain(": string");
82 expect(source).not.toContain(": boolean");
83 + expect(recreated("0.5.0", "^0")).toBe(true);
84 + expect(recreated("0.0.4", "^0.0")).toBe(true);
85 expect(recreated("24.10.0", ">=24.10")).toBe(true);
86 expect(recreated("24.9.9", ">=24.10")).toBe(false);
87 });
packages/shared/src/semver.ts
+2 -2
@@ -198,10 +198,10 @@ export const satisfiesSemverRange: (rawVersion: string, range: string) => boolea
198 if (compared < 0) {
199 return false;
200 }
201 - if (target.major > 0) {
201 + if (target.major > 0 || targetMatch[2] === undefined) {
202 return version.major === target.major;
203 }
204 - if (target.minor > 0) {
204 + if (target.minor > 0 || targetMatch[3] === undefined) {
205 return version.major === 0 && version.minor === target.minor;
206 }
207 return version.major === 0 && version.minor === 0 && version.patch === target.patch;