convert-color: color names should be case insensitive (#25140)

convert-color: colornames should be case insensitive
This commit is contained in:
karwosts 2025-04-22 22:14:53 -07:00 committed by GitHub
parent 48c90267df
commit 4c6a5ed2e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -144,7 +144,7 @@ export function theme2hex(themeColor: string): string {
return themeColor;
}
const rgbFromColorName = colors[themeColor];
const rgbFromColorName = colors[themeColor.toLowerCase()];
if (rgbFromColorName) {
return rgb2hex(rgbFromColorName);
}

View File

@ -48,6 +48,7 @@ describe("Color Conversion Tests", () => {
it("should convert theme color to hex (ignoring alpha)", () => {
expect(theme2hex("red")).toBe("#ff0000");
expect(theme2hex("ReD")).toBe("#ff0000");
expect(theme2hex("#ff0000")).toBe("#ff0000");
expect(theme2hex("unicorn")).toBe("unicorn");
expect(theme2hex("#abc")).toBe("#aabbcc");