Skip to content

Commit 6cbe17f

Browse files
committed
add normalize mintype
1 parent 5642ae5 commit 6cbe17f

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

src/tests/mcp-apps.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ describe('MCP Apps capability detection', () => {
5353
expect(supportsMcpAppsCapability(supportedCapabilities)).toBe(true);
5454
});
5555

56+
test.each([
57+
' text/html;profile=mcp-app ',
58+
'text/html; profile=mcp-app',
59+
'text/html; profile="mcp-app"',
60+
'TEXT/HTML; PROFILE="MCP-APP"',
61+
])('normalizes the advertised MIME type %s', (mimeType) => {
62+
const capabilities = {
63+
extensions: {
64+
[MCP_APPS_EXTENSION_ID]: {
65+
mimeTypes: [mimeType],
66+
},
67+
},
68+
};
69+
70+
expect(supportsMcpAppsCapability(capabilities)).toBe(true);
71+
});
72+
5673
test.each([
5774
undefined,
5875
{},

src/ui/mcp-apps.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ export function supportsMcpAppsCapability(capabilities: unknown): boolean {
2727
return false;
2828
}
2929

30-
return uiCapability.mimeTypes.includes(MCP_APP_MIME_TYPE);
30+
return uiCapability.mimeTypes.some((mimeType) => {
31+
if (typeof mimeType !== 'string') {
32+
return false;
33+
}
34+
35+
return normalizeMimeType(mimeType) === MCP_APP_MIME_TYPE;
36+
});
3137
}
3238

3339
export function clientSupportsMcpApps(
@@ -47,3 +53,7 @@ export function clientSupportsMcpApps(
4753
function isRecord(value: unknown): value is Record<string, unknown> {
4854
return typeof value === 'object' && value !== null;
4955
}
56+
57+
function normalizeMimeType(mimeType: string): string {
58+
return mimeType.replace(/[\s"]/g, '').toLowerCase();
59+
}

0 commit comments

Comments
 (0)