fix(home): isSvg handles URLs with query strings and fragments#3950
fix(home): isSvg handles URLs with query strings and fragments#3950PierreBrisorgueil merged 2 commits intomasterfrom
Conversation
Strip `?query` and `#fragment` from the img URL before the `.endsWith('.svg')`
check so cache-busted paths like `/images/foo.svg?v=2` are still inlined via
`v-html` and can resolve Vuetify theme CSS vars.
Previously, any SVG with `?v=N` fell back to `<v-img>` which rendered it as a
raster-like `<img>` whose internal `rgb(var(--v-theme-...))` references stayed
unresolved — SVGs appeared solid black in light mode.
Adds 8 unit tests covering `.svg`, `.svg?v=2`, `.svg?v=2&t=3`, `.svg#frag`,
`.svg?v=2#frag`, absolute URLs with query, `.png`, `.png?v=2`.
Fixes #3949
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3950 +/- ##
=======================================
Coverage 99.46% 99.46%
=======================================
Files 29 29
Lines 940 940
Branches 252 252
=======================================
Hits 935 935
Misses 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes HomeImgComponent’s isSvg() detection so local SVG URLs with ?query strings and/or #fragments are still treated as SVGs and rendered inline (via v-html), preserving Vuetify theme CSS variable resolution.
Changes:
- Update
isSvg()to strip query string + fragment before checking for the.svgextension. - Add unit tests covering local SVG URLs with query/fragment variations and ensuring non-SVG / absolute URLs are not inlined.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/modules/home/components/utils/home.img.component.vue | Adjusts SVG detection logic to ignore ?/# when determining file extension. |
| src/modules/home/tests/home.img.component.unit.tests.js | Adds test coverage for the updated SVG URL detection behavior. |
Addresses Copilot review on #3950: use an immediately-resolving { ok: false } fetch mock and unmount each wrapper to avoid leaking DOM/component instances across the isSvg URL detection tests.
Summary
isSvg()inhome.img.component.vueto strip?queryand#fragmentbefore the.endsWith('.svg')extension check./images/foo.svg?v=2are now inlined viav-html(the documented/svg-generatorbehaviour), so SVGs referencing Vuetify theme CSS vars (rgb(var(--v-theme-surface))) resolve correctly in both light and dark mode..svg,.svg?v=2,.svg?v=2&t=3,.svg#frag,.svg?v=2#frag, absolute URLs with query,.png, and.png?v=2.Root cause
'foo.svg?v=3'.endsWith('.svg')isfalse, so the inline branch was skipped and the file fell through to<v-img>— rendering the SVG as a raster-like<img>where internal CSS custom property references never resolve. The result: SVGs that depend onrgb(var(--v-theme-...))showed solid black in light mode. Hit while polishing the trawl.me landing page (trawl-dev-pipeline.svg,trawl-business-alert.svg).This was fixed once in #471 but lost during the stack update in #474.
Fix
3-line change, no behaviour change for URLs without a query string.
Downstream
comes-io/trawl_vuePR #475 carries an identical hotfix on thefeat/landing-polish-v4branch. Once this devkit PR merges, the downstream copy can be reverted and picked up from the next stack update.Test plan
npm run lintnpm run test:coverage— 941/941 passing, coverage thresholds intactnpm run buildFixes #3949
Summary by CodeRabbit
Bug Fixes
Tests