@devries-cameron20 / t3code Mirror · read-only / commits / 2b1e15c999
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, 12:00 UTC

fix(shared): preserve hyphens in prerelease versions (#23430)

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

Aditya Garud committed Oct 31, 2026 at 02:18 UTC 2b1e15c999aed3b8a06238b467d74f9cd9a1aeae
2 files changed +23 -2
packages/shared/src/semver.test.ts
+18
@@ -35,6 +35,24 @@ describe("semver helpers", () => {
35 expect(compareSemverVersions("2.1.111-beta.1", "2.1.111")).toBeLessThan(0);
36 });
37
38 + it("preserves hyphens within prerelease identifiers", () => {
39 + expect(normalizeSemverVersion("20-alpha-1")).toBe("20.0.0-alpha-1");
40 + expect(parseSemver("1.2.3-alpha-1.2")).toEqual({
41 + major: 1,
42 + minor: 2,
43 + patch: 3,
44 + prerelease: ["alpha-1", "2"],
45 + });
46 + expect(parseSemver("1.2.3-x-y-z.--")?.prerelease).toEqual(["x-y-z", "--"]);
47 + });
48 +
49 + it("distinguishes releases whose identifiers differ after a hyphen", () => {
50 + expect(compareSemverVersions("1.2.3-alpha-1", "1.2.3-alpha-2")).toBeLessThan(0);
51 + expect(compareSemverVersions("1.2.3-alpha-2", "1.2.3-alpha-1")).toBeGreaterThan(0);
52 + expect(compareSemverVersions("1.2.3-alpha-1.2", "1.2.3-alpha-1.10")).toBeLessThan(0);
53 + expect(compareSemverVersions("1.2.3-alpha.1+build-2", "1.2.3-alpha.1+build-3")).toBe(0);
54 + });
55 +
56 it("supports comparison comparators", () => {
57 expect(satisfiesSemverRange("24.9.0", ">=24.0 <24.10")).toBe(true);
58 expect(satisfiesSemverRange("24.10.0", ">=24.0 <24.10")).toBe(false);
packages/shared/src/semver.ts
+5 -2
@@ -8,7 +8,9 @@ interface ParsedSemver {
8 const SEMVER_NUMBER_SEGMENT = /^\d+$/;
9
10 export function normalizeSemverVersion(version: string): string {
11 - const [main, prerelease] = version.trim().split("-", 2);
11 + const [versionWithoutBuildMetadata = ""] = version.trim().split("+", 1);
12 + const [main, ...prereleaseParts] = versionWithoutBuildMetadata.split("-");
13 + const prerelease = prereleaseParts.join("-");
14 const segments: string[] = [];
15 for (const segment of (main ?? "").split(".")) {
16 const trimmed = segment.trim();
@@ -26,7 +28,8 @@ export function normalizeSemverVersion(version: string): string {
28
29 export function parseSemver(value: string): ParsedSemver | null {
30 const normalized = normalizeSemverVersion(value).replace(/^v/, "");
29 - const [main = "", prerelease] = normalized.split("-", 2);
31 + const [main = "", ...prereleaseParts] = normalized.split("-");
32 + const prerelease = prereleaseParts.join("-");
33 const segments = main.split(".");
34 if (segments.length !== 3) {
35 return null;