diff --git a/index.html b/index.html index 96ca674..9f35739 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ diff --git a/package.json b/package.json index 1f24d38..7ae5550 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ztimson/utils", - "version": "0.23.8", + "version": "0.23.9", "description": "Utility library", "author": "Zak Timson", "license": "MIT", diff --git a/src/color.ts b/src/color.ts index 9011690..36fa6e4 100644 --- a/src/color.ts +++ b/src/color.ts @@ -4,7 +4,7 @@ * @return {"white" | "black"} Color with the most contrast */ export function blackOrWhite(background: string): 'white' | 'black' { - const exploded = background.match(background.length >= 6 ? /\w\w/g : /\w/g); + const exploded = background?.match(background.length >= 6 ? /\w\w/g : /\w/g); if(!exploded) return 'black'; const [r, g, b] = exploded.map(hex => parseInt(hex, 16)); const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;