fix(marketplace): use external icon URL when icon field is absolute

Many MCP / skill records store their icon as an absolute external URL
(simpleicons.org / iconify.design) rather than an uploaded file, so the
/resources/icon endpoint 404s and the card icon breaks. Add
resolveMarketplaceIconURL() which prefers an absolute http(s) icon field
and otherwise falls back to the resources endpoint.
This commit is contained in:
RockChinQ
2026-06-06 03:52:09 -04:00
parent f54ae4b91c
commit dff80a0c0a
4 changed files with 44 additions and 18 deletions
@@ -230,6 +230,29 @@ export class CloudServiceClient extends BaseHttpClient {
return `${this.baseURL}/api/v1/marketplace/skills/${author}/${name}/resources/icon`;
}
/**
* Resolve the best icon URL for a marketplace extension.
*
* Many MCP / skill records store their ``icon`` as an absolute external URL
* (e.g. simpleicons.org / iconify.design logos) rather than a file uploaded
* to Space storage. For those, the ``/resources/icon`` endpoint 404s, so we
* must use the external URL directly. Records whose ``icon`` is empty or a
* relative path fall back to the ``/resources/icon`` endpoint (real uploads).
*/
public resolveMarketplaceIconURL(
type: 'plugin' | 'mcp' | 'skill' | undefined,
author: string,
name: string,
icon?: string,
): string {
if (icon && /^https?:\/\//i.test(icon)) {
return icon;
}
if (type === 'mcp') return this.getMCPMarketplaceIconURL(author, name);
if (type === 'skill') return this.getSkillMarketplaceIconURL(author, name);
return this.getPluginIconURL(author, name);
}
public getPluginAssetURL(
author: string,
pluginName: string,