From b1a04fce772a0fca4c14f1e3758a8ba5c7c77ad5 Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Wed, 10 Jan 2024 10:46:55 +0100 Subject: [PATCH] fix: improve performance of `isColor` detection for long text values (See #378) --- src/lib/utils/typeUtils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/utils/typeUtils.ts b/src/lib/utils/typeUtils.ts index 0b67d407..7bbd3faa 100644 --- a/src/lib/utils/typeUtils.ts +++ b/src/lib/utils/typeUtils.ts @@ -92,7 +92,8 @@ export function getColorCSS(color: string): string | null { * Returns true if a valid color, false otherwise */ export function isColor(value: unknown): boolean { - return typeof value === 'string' && !!getColorCSS(value) + const maxColorLength = 99 + return typeof value === 'string' && value.length < maxColorLength && !!getColorCSS(value) } /**