Skip to content

Commit b569b56

Browse files
committed
Match preset icons on exact tokens only
1 parent 1302074 commit b569b56

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

packages/react/src/components/integration-favicon.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,27 @@ describe("IntegrationFavicon", () => {
273273
).toBe("https://example.com/spotify.png");
274274
});
275275

276+
it("does not match a different brand sharing a word fragment (ClickHouse Cloud vs Cloudflare)", () => {
277+
expect(
278+
integrationPresetIconUrl({ id: "clickhouse", kind: "mcp", name: "ClickHouse Cloud" }, [
279+
{
280+
key: "mcp",
281+
label: "MCP",
282+
add: () => null,
283+
edit: () => null,
284+
presets: [
285+
{
286+
id: "cloudflare",
287+
name: "Cloudflare",
288+
summary: "Workers, KV, D1, R2, and DNS management via MCP.",
289+
icon: "https://integrations.sh/logo/cloudflare.com",
290+
},
291+
],
292+
},
293+
]),
294+
).toBeNull();
295+
});
296+
276297
it("infers favicon URLs from migrated host-shaped MCP names and slugs", () => {
277298
expect(integrationInferredUrl({ id: "mcp_posthog_com", name: "mcp.posthog.com" })).toBe(
278299
"https://mcp.posthog.com",

packages/react/src/components/integration-favicon.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ export function integrationInferredUrl(integration: {
129129
return null;
130130
}
131131

132+
// Exact equality only: substring containment matched unrelated brands that
133+
// merely share a fragment ("ClickHouse Cloud" ⊂ "Cloudflare" via "cloud"). A
134+
// missed match is recoverable (the cascade falls through to the domain-derived
135+
// integrations.sh favicon); a wrong-brand icon is not.
132136
const tokenMatches = (integrationValue: string, presetValue: string): boolean =>
133-
presetValue.length > 0 &&
134-
integrationValue.length > 0 &&
135-
(integrationValue === presetValue ||
136-
integrationValue.includes(presetValue) ||
137-
presetValue.includes(integrationValue));
137+
presetValue.length > 0 && integrationValue === presetValue;
138138

139139
export function integrationPresetIconUrl(
140140
integration: {

0 commit comments

Comments
 (0)