From 6c25e55aab6f6b69906c345c09bd0ca5852fdc17 Mon Sep 17 00:00:00 2001 From: Kieron Lanning Date: Fri, 13 Nov 2026 11:47:02 +0000 Subject: [PATCH] test: match inlined svg icons regardless of whitespace and quotes LikeC4 inlines local SVG icons as data: URIs, and the encoder collapses whitespace and swaps double quotes for single. The smoke check compared the raw first 60 characters of the file, which only matched because the playground's demo.svg has no line break near its start. Strip whitespace and quotes on both sides before comparing. --- scripts/smoke.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/smoke.ts b/scripts/smoke.ts index 2d79f2d..fe60480 100644 --- a/scripts/smoke.ts +++ b/scripts/smoke.ts @@ -121,12 +121,16 @@ if (packIconCount === 0) { const leaked = [...imageIconSrcs].filter((src) => src.startsWith('file://')); if (leaked.length > 0) failures.push(`Icons: build-machine path reached an — ${leaked[0]}`); -/** LikeC4 inlines some local SVGs as `data:` URIs, so either form counts. */ +/** + * LikeC4 inlines some local SVGs as `data:` URIs, so either form counts. The + * encoder collapses whitespace and swaps quotes, so compare with both stripped. + */ function rendered(url: string, file: URL): boolean { - const svg = readFileSync(file, 'utf8').trim(); + const normalise = (svg: string) => svg.replace(/\s+|["']/g, ''); + const svg = normalise(readFileSync(file, 'utf8')).slice(0, 120); return [...imageIconSrcs].some( - (src) => src === url || (src.startsWith('data:image/svg+xml') && decodeURIComponent(src).includes(svg.slice(0, 60).replaceAll('"', "'"))), + (src) => src === url || (src.startsWith('data:image/svg+xml') && normalise(decodeURIComponent(src)).includes(svg)), ); }