From 9f4fc933cf54c927e490d3ba858f113fadd916d7 Mon Sep 17 00:00:00 2001 From: soraefir Date: Mon, 8 Jun 2026 21:09:51 +0200 Subject: [PATCH] fix color --- modules/server/containers/apps/favicon.nix | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/modules/server/containers/apps/favicon.nix b/modules/server/containers/apps/favicon.nix index 77b8aaf..78b19e7 100644 --- a/modules/server/containers/apps/favicon.nix +++ b/modules/server/containers/apps/favicon.nix @@ -139,22 +139,24 @@ let return None, DEFAULT_PROFILE def _replace_svg_color(svg, attribute, color): - if attribute in {"fill", "stroke"}: - svg = re.sub( - rf'{attribute}="(?!none\\b)[^"]*"', - f'{attribute}="{color}"', - svg, - flags=re.IGNORECASE, - ) - svg = re.sub( - rf"{attribute}='(?!none\\b)[^']*'", - f"{attribute}='{color}'", - svg, - flags=re.IGNORECASE, - ) + if attribute not in {"fill", "stroke"}: + return svg + + svg = re.sub( + rf'({attribute}\\s*=\\s*")(?!none\\b)[^"]*(")', + rf"\\1{color}\\2", + svg, + flags=re.IGNORECASE, + ) + svg = re.sub( + rf"({attribute}\\s*=\\s*')(?!none\\b)[^']*(')", + rf"\\1{color}\\2", + svg, + flags=re.IGNORECASE, + ) return re.sub( - rf"{attribute}\\s*:\\s*(?!none\\b)[^;\"\\']+", - f"{attribute}:{color}", + rf"({attribute}\\s*:\\s*)(?!none\\b)[^;\"']+", + rf"\\1{color}", svg, flags=re.IGNORECASE, )