fix: detect .svg uris with a query, fragment or upper case extension - #1091
Open
afonsograca wants to merge 1 commit into
Open
fix: detect .svg uris with a query, fragment or upper case extension#1091afonsograca wants to merge 1 commit into
afonsograca wants to merge 1 commit into
Conversation
Renderer.image() tested uri.endsWith(".svg"). Addresses such as
logo.svg?v=1 or LOGO.SVG went to MDImage, which cannot draw an SVG,
and the image was blank. Remove the query string and the fragment
before the test, and ignore the letter case.
afonsograca
force-pushed
the
fix/svg-uri-detection
branch
from
September 10, 2026 08:18
1936e4d to
585af3c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As a user, I should see an SVG image when its address has a query string or a fragment. Many SVG assets come from a CDN. These addresses often hold a signature or a cache-busting parameter, for example
logo.svg?v=1. Today these images are blank.In this PR we correct the test that finds an SVG address:
Renderer.image()testeduri.endsWith(".svg"). An address with a query string or a fragment failed this test. The address then went toMDImage.MDImagecannot draw an SVG file, and the image was blank.logo.svg?v=1,LOGO.SVGandlogo.svg#topnow go toMDSvg.https://example.com/logo.svg?v=1. The other test useshttps://example.com/LOGO.SVG#top. Both tests use the existingfetchmock, and both tests check thatMDSvgrenders.Markdown.spec.tsxuse a plain.svgaddress.The predicate is
/\.svg$/i.test(uri.split(/[?#]/, 1)[0] ?? ""). The repository setsnoUncheckedIndexedAccess, so the index givesstring | undefined. The?? ""givesRegExp.test()astring.Renderer.image()is the only place that finds an SVG address, so one change is sufficient.The new tests use the
fetchmock that #1089 added.