Repository navigation
Conversation
stac-js 0.5.3 leaves image/svg+xml out of browserImageTypes. Its getIcons() therefore drops every SVG icon. The Portolan profile allows SVG icons (PORTO-CORE-075), and the Portolan pipeline publishes SVG icons for browsing groups. Utils.getIcons() now accepts an icon link when stac-js accepts it or when the link is an SVG on http, https or a relative href. StacLink and Utils.getIcon() use it. Thumbnails and previews do not change. The browser renders icons only through <img>. An SVG in <img> runs no scripts and loads no external resources.
|
@yharby is this still a draft? |
Author
|
I was waiting for moregeo-it/stac-js#26 and radiantearth#1021 CC @m-mohr |
|
Does someone have a voucher for the 48 hour day upgrade, please? 🙈😅 (currently at 12.5 hours at work) |
|
@m-mohr I can lend you some claude credits ;) |
|
That's not how I work, at least for reviews 😐 I'll try my best to get to it soon. |
This branch has not been deployed
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.
What changed
The browser now shows SVG icons from
rel=iconlinks. The change applies to these places:Before this change, an icon with
"type": "image/svg+xml"did not appear anywhere. PNG, JPEG, GIF and WebP icons behave as before.Thumbnails, overviews and
previewlinks do not change. They still accept only the stac-js raster types.Why
The Portolan profile allows
image/svg+xmlicons (PORTO-CORE-075).The Portolan pipeline now publishes SVG group icons. Each icon is a file under
_assets/icons/. The pipeline change is https://github.com/CartoDB/portolan-pipeline/pull/110.The stac-js release in use is
0.5.3. It leavesimage/svg+xmlout ofbrowserImageTypesinsrc/mediatypes.js.STAC.getIcons()filters oncanBrowserDisplayImage(), so it drops each SVG icon.Verification
The fixture is a local static catalog at
http://localhost:8111/catalog.json. It has one child catalog,roads/catalog.json, with this link:{"rel":"icon","href":"../_assets/icons/x.svg","type":"image/svg+xml","title":"X"}The SVG is a 24 x 24 cross with a fixed stroke colour, no script and no external reference. I served the fixture with CORS and ran
npx vite --port 5199. Then I read the<img>elements in Playwright.Root page,
http://localhost:5199/#/external/http://localhost:8111/catalog.json, with this branch:Child page,
#/external/http://localhost:8111/roads/catalog.json, with this branch:Root page with the change removed from
src/utils.jsandsrc/components/StacLink.vue:The card shows no icon in that case. A screenshot of the fixed root page shows the red cross beside "Roads".
Checks on this branch:
requests (a release or integration branch). List them under "What
changed".
Implementation notes
Utils.getIcons(data)insrc/utils.jskeeps an icon link in two cases:canBrowserDisplayImage(true)accepts the linkUtils.isBrowserSvg()accepts the linkUtils.isBrowserSvg()repeats the stac-js protocol check. It accepts these links:http,httpsor relative hrefimage/svg+xmltype, or no type with a.svgextensionIt rejects
s3://and other protocols. The missing-type rule matches theallowUndefined = truedefault ofgetIcons().Utils.getIcon()andStacLink.vuenow callUtils.getIcons(). They are the only callers ofgetIcons()insrc/.Safety: the browser renders each icon through
<img :src>. It never puts SVG markup into the DOM. An SVG in<img>runs no scripts. It also loads no external resources.The new unit tests in
tests/unit/utils.spec.jscover these cases:.svgicons3://SVG iconA follow-up in stac-js upstream can add
image/svg+xmltobrowserImageTypes. That change also affects thumbnails, so upstream must decide the scope. After an upstream release,Utils.isBrowserSvg()can go.Related issues
https://github.com/CartoDB/portolan-pipeline/issues/154
https://github.com/CartoDB/portolan-pipeline/pull/110