From 4c6a5ed2e31a8c26737515d66d13965cf139e70b Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Tue, 22 Apr 2025 22:14:53 -0700 Subject: [PATCH] convert-color: color names should be case insensitive (#25140) convert-color: colornames should be case insensitive --- src/common/color/convert-color.ts | 2 +- test/common/color/convert-color.test.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/color/convert-color.ts b/src/common/color/convert-color.ts index f325aef1fd..f6bbcd2c24 100644 --- a/src/common/color/convert-color.ts +++ b/src/common/color/convert-color.ts @@ -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); } diff --git a/test/common/color/convert-color.test.ts b/test/common/color/convert-color.test.ts index 57907f764b..adcd846781 100644 --- a/test/common/color/convert-color.test.ts +++ b/test/common/color/convert-color.test.ts @@ -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");