mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
fix(app): treat a black instance theme colour as unset (#3502)
This commit is contained in:
1 parent
41da6b5985
commit
b9ea837c75
5 files changed
+34
-20
No files matched your search
@@ -0,0 +1,13 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
const HEX_THEME_COLOR_PATTERN = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
||||
const UNSET_THEME_COLOR = '#000000';
|
||||
|
||||
export function normalizeThemeColor(value: unknown): string | null {
|
||||
if (typeof value !== 'string') return null;
|
||||
const match = HEX_THEME_COLOR_PATTERN.exec(value.trim());
|
||||
if (match === null) return null;
|
||||
const digits = match[1].toLowerCase();
|
||||
const color = `#${digits.length === 3 ? digits.replace(/./g, '$&$&') : digits}`;
|
||||
return color === UNSET_THEME_COLOR ? null : color;
|
||||
}
|
||||
Reference in new issue
Block a user