mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 20:35:39 -06:00
fix(ui): allow short tweakcn theme ids
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user