Repository navigation
fix(resource): exclude inline payloads from fallback searches - #269
Conversation
|
@cangen185-sudo Help to give a bad case show the before and after. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the fallback-search changes.
No open issues 🎉
What changed in this PR
Fixes resource fallback searches so failed inline SVG and image payloads are not used as search queries. Searchable configuration text retains priority; excluded or empty data falls back to the item context or scene default.
Changes:
- Applies inline, data-URI, and SVG exclusions before accepting configured search text.
- Adds 11 regression cases covering fallback selection, query priority, and unchanged successful primary loading.
| File | Description |
|---|---|
src/resource/loader.ts |
Reorders fallback query selection to exclude payloads before using item context or defaults. |
__tests__/unit/resource/loader.test.ts |
Adds regression coverage for fallback queries and successful primary loading. |
Review effort: Balanced
|
@hustcc Here’s a concrete before/after. The item is labelled Computer network, but its inline SVG is truncated and cannot load: await loadResource(
svg,
'icon',
{ source: 'inline', format: 'svg', encoding: 'raw', data: '<svg broken' },
{ label: 'Computer network' },
);I ran the fallback-query function from base
Previously the search provider received the markup itself. With the patch it can look up the subject of the item. The exact artwork depends on the provider. The regression test checks the query through |
Failed inline SVG/image resources currently use their raw payload as an icon-search query.
getFallbackQuery()returnscfg.databefore reaching its existing inline/data-URI/SVG exclusions, so an item label, description, or the defaulticon/illustrationquery is never selected for nonempty inline data.Apply those exclusions before accepting the configured query. Preserve the current priority of searchable configuration text, including bare icon names such as
plane; only fall back to the item context and scene default when the configured data is excluded or empty. Successful primary loading is unchanged.Validation on main
5ae0d9394ac6280cb688eb4b4345881e291b9209:loadResource; the original code fails 8 and passes 3, while the patch passes all 11.npm run build:esm,npm run check:test, and ESLint/Prettier on the two changed files passed.This PR was prepared with AI assistance. Local validation used Windows and Node.js 24; the repository's macOS/Node.js 20 CI remains the remote validation boundary.