Skip to content

test: match inlined svg icons regardless of whitespace and quotes - #24

Merged
kieronlanning merged 1 commit into
mainfrom
smoke-inlined-icon-whitespace
Nov 13, 2026
Merged

kieronlanning merged 1 commit into
mainfrom
smoke-inlined-icon-whitespace

Conversation

@kieronlanning

Copy link
Copy Markdown
Contributor

What

scripts/smoke.ts — rendered() now strips whitespace and quotes from both the icon file and the decoded data: URI before comparing (first 120 normalised characters).

Why

LikeC4 inlines local SVG icons as data:image/svg+xml URIs, and the encoder collapses whitespace and swaps " for '. The old check compared the raw first 60 characters of the file, which only worked because the playground's demo.svg has no line break near its start. An icon that opens with <?xml …?> followed by a newline (or an indented comment) renders correctly but fails the check.

Found while upgrading a consuming site to 1.0.0-prerelease.8: its own copy of this check reported a self-hosted icon as missing, though a browser showed it on every node.

Changes

Test-only. No change to the package, so no version bump.

Verification

  • bunx tsc -p tsconfig.scripts.json --noEmit
  • bun run build, then bun scripts/smoke.ts against the built playground — passes, including the self-hosted public/ icon and the /_astroc4/ aliased icon.

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.
@kieronlanning
kieronlanning merged commit d62c57b into main Nov 13, 2026
4 checks passed
@kieronlanning
kieronlanning deleted the smoke-inlined-icon-whitespace branch November 13, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant