From c4841575c91fd1688e9dc2170a75d09ebae70e90 Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Wed, 18 Mar 2026 20:23:22 +0100 Subject: [PATCH] fix(ot): use default color constant for hex2rgb fallback Co-authored-by: Philip Molares Signed-off-by: Erik Michelson --- public/vendor/ot/hex2rgb.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/vendor/ot/hex2rgb.js b/public/vendor/ot/hex2rgb.js index 7e1de864..47f0134a 100644 --- a/public/vendor/ot/hex2rgb.js +++ b/public/vendor/ot/hex2rgb.js @@ -1,16 +1,18 @@ +const defaultColor = { red: 0, green: 0, blue: 0 } + function hex2rgb (hex) { - if (!hex || typeof hex !== 'string') return { red: 0, green: 0, blue: 0 } + if (!hex || typeof hex !== 'string') return defaultColor if (hex[0] == '#') hex = hex.substr(1) if (hex.length == 3) { var temp = hex hex = '' var match = /^([a-f0-9])([a-f0-9])([a-f0-9])$/i.exec(temp) - if (!match) return { red: 0, green: 0, blue: 0 } + if (!match) return defaultColor temp = match.slice(1) for (var i = 0; i < 3; i++) hex += temp[i] + temp[i] } var result = /^([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i.exec(hex) - if (!result) return { red: 0, green: 0, blue: 0 } + if (!result) return defaultColor var triplets = result.slice(1) return { red: parseInt(triplets[0], 16),