Skip to content

fix(core): preserve images with commas in srcset URLs - #6192

Merged
jrusso1020 merged 1 commit into
heygen-com:mainfrom
AksharP5:srcset-urls
Oct 24, 2026
Merged

jrusso1020 merged 1 commit into
heygen-com:mainfrom
AksharP5:srcset-urls

Conversation

@AksharP5

Copy link
Copy Markdown
Contributor

What

Images supplied through a data URL in srcset disappear when a project is bundled. Bundling now preserves complete candidate URLs, including commas in data URLs and image filenames, through both rebasing and asset inlining.

Why

The authored image loads, but bundling inserts a space after its data-URL comma. The CLI can successfully capture a frame containing a broken image.

Same 320×180 composition, Chrome 152, CLI snapshot at 0.5 seconds:

Observation Main 0d104e6fc This PR
Bundled image natural size 0×0 160×90
Red pixels in captured frame 0 14,400 (full 160×90 rectangle)
Failed-image warnings 1 0

The issue includes the complete fixture and commands. This is an actual browser/CLI comparison. A full one-second, 30 fps MP4 export also passes; the decoded frame preserves the rectangle.

Related work

Fixes #6191.

#6134 changes the same bundler for a total inlining-size budget. #5298 handles capture selection for srcset-only images. This change is limited to candidate URL rewriting.

How

One private scanner replaces the two comma-splitting helpers. It follows the HTML srcset URL and descriptor boundaries and changes only URL spans, leaving descriptors and separators intact. Both <img> and <source> use it; no dependency or public API is added.

Test plan

  • Five regression cases fail on main and pass with the fix: data/remote URL commas, comma-named local assets, nested picture entries, and both inlining options.
  • 206 Core bundling/entry/media identity tests and 7 CLI bundling tests pass.
  • Actual CLI lint, browser check, matching before/after snapshots, and a full 30-frame MP4 export pass; inspected the captured and decoded frames.
  • Core build, lint, formatting, workspace contracts, package-cycle check, and comment checks pass.
  • Independent GPT-6.1 Sol xhigh review: no blockers; 191 bundler tests, 21 adjacent tests, and a 192-assertion grammar matrix against source and built Node output pass.
  • Documentation updated.
  • Comments explain the URL boundary and link the HTML specification.

Full workspace build is limited by missing checkout dependencies in inspector/AWS packages. Mintlify CLI is unavailable locally; no packages were installed.

@mintlify

mintlify Bot commented Oct 24, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit c9ec34a.

Approve preview

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at c9ec34aa. The bug is real on main, the scanner follows the HTML srcset rules, and the tests guard it.

What I verified:

  • On main, both rebaseSrcsetPaths and rewriteSrcsetWithInlinedAssets split the attribute on every comma, so a data: candidate (and a file like hero,blue.png) is cut in two and rejoined with a space. #6191 is still open and no other open PR covers it.
  • I walked rewriteSrcsetUrls against the spec's parse-a-srcset algorithm: skip whitespace and commas, take the URL as the run of non-whitespace, strip trailing commas (and skip descriptors when it had any), then read descriptors up to the next comma that is not inside parentheses. It matches, and it only rewrites URL spans, so descriptors and the author's separators are left as written.
  • Applied onto current main, htmlBundler.test.ts passes 191 of 191. With only htmlBundler.ts reverted, all 5 new cases fail.
  • Merging the two helpers into one scanner with a URL callback is a nice simplification. Two copies of the splitting logic become one.

A non-blocking follow-up: the same naive comma split still exists in two other places. rewriteSrcsets in packages/cli/src/cloud/offload.ts skips any srcset containing data: but would still break a comma-named file, and the srcset regex in packages/studio-server/src/routes/files.ts treats every comma as a separator. If this scanner were exported from core, those sites could use it too. Not needed for this fix.

Need: yes, bundling breaks data-URL srcset images today · Size: ok · Reuse: consolidates the two existing helpers; offload.ts and studio-server could reuse it later · Simpler: already minimal

— Rames

@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 24, 2026
Merged via the queue into heygen-com:main with commit 73dda71 Oct 24, 2026
81 checks passed
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.

Bundling corrupts data URLs in image srcset

2 participants