Repository navigation
fix(core): preserve images with commas in srcset URLs - #6192
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
jrusso1020
left a comment
There was a problem hiding this comment.
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
rebaseSrcsetPathsandrewriteSrcsetWithInlinedAssetssplit the attribute on every comma, so adata:candidate (and a file likehero,blue.png) is cut in two and rejoined with a space. #6191 is still open and no other open PR covers it. - I walked
rewriteSrcsetUrlsagainst 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.tspasses 191 of 191. With onlyhtmlBundler.tsreverted, 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
What
Images supplied through a data URL in
srcsetdisappear 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:
0d104e6fcThe 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
Full workspace build is limited by missing checkout dependencies in inspector/AWS packages. Mintlify CLI is unavailable locally; no packages were installed.