diff --git a/ui/src/ui/custom-theme.test.ts b/ui/src/ui/custom-theme.test.ts index da42d5d2b8ba..d922a6a325fb 100644 --- a/ui/src/ui/custom-theme.test.ts +++ b/ui/src/ui/custom-theme.test.ts @@ -112,6 +112,16 @@ describe("custom theme import helpers", () => { fetchUrl: "https://tweakcn.com/r/themes/amethyst-haze", themeId: "amethyst-haze", }); + expect(normalizeTweakcnThemeUrl("https://tweakcn.com/r/themes/claude")).toEqual({ + sourceUrl: "https://tweakcn.com/themes/claude", + fetchUrl: "https://tweakcn.com/r/themes/claude", + themeId: "claude", + }); + expect(normalizeTweakcnThemeUrl("twitter")).toEqual({ + sourceUrl: "https://tweakcn.com/themes/twitter", + fetchUrl: "https://tweakcn.com/r/themes/twitter", + themeId: "twitter", + }); }); it("maps a tweakcn payload into a normalized imported theme record", () => { @@ -267,6 +277,7 @@ describe("custom theme import helpers", () => { throw new Error("Expected imported custom theme to parse"); } expect(parsed.themeId).toBe("cmlhfpjhw000004l4f4ax3m7z"); + expect(parseImportedCustomTheme({ ...imported, themeId: "claude" })?.themeId).toBe("claude"); expect(parseImportedCustomTheme({ ...imported, light: {} })).toBeNull(); }); diff --git a/ui/src/ui/custom-theme.ts b/ui/src/ui/custom-theme.ts index 6e595d2815ee..458de75bad3e 100644 --- a/ui/src/ui/custom-theme.ts +++ b/ui/src/ui/custom-theme.ts @@ -3,7 +3,7 @@ import { z } from "zod"; import { normalizeOptionalString } from "./string-coerce.ts"; const TWEAKCN_HOSTS = new Set(["tweakcn.com", "www.tweakcn.com"]); -const THEME_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{7,127}$/; +const THEME_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/; const CUSTOM_THEME_STYLE_ID = "openclaw-custom-theme"; const MAX_TWEAKCN_THEME_BYTES = 200_000; const MAX_CSS_TOKEN_LENGTH = 240;