fix(ui): allow short tweakcn theme ids

This commit is contained in:
Vincent Koc
2026-06-06 08:29:44 -07:00
parent 97758910fa
commit 16921dba7d
2 changed files with 12 additions and 1 deletions
+11
View File
@@ -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();
});
+1 -1
View File
@@ -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;