1
0
mirror of https://github.com/flarum/core.git synced 2025-08-03 23:17:43 +02:00

fix: 3 char hex color is incorrectly modified to 6 (#4013)

The current logic creates `cdecde` from `cde`, it should be `ccddee`.

@dsevillamartin said this is the code to use instead and chat gpt said he's brilliant so..
This commit is contained in:
Daniël Klabbers
2024-08-08 15:50:09 +02:00
committed by GitHub
parent 6b336c5ea8
commit 6663b5dff0

View File

@@ -17,7 +17,7 @@ export default function isDark(hexcolor: string | null): boolean {
let hexnumbers = hexcolor.replace('#', '');
if (hexnumbers.length === 3) {
hexnumbers += hexnumbers;
hexnumbers = hexnumbers.split('').map(char => char.repeat(2)).join('');
}
const r = parseInt(hexnumbers.slice(0, 2), 16);