diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index a4325c2..f0b166e 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -794,8 +794,6 @@ export const ChatRowContent = ({ {useMcpServer.type === "access_mcp_resource" && ( )} diff --git a/webview-ui/src/components/mcp/McpResourceRow.tsx b/webview-ui/src/components/mcp/McpResourceRow.tsx index ac23f96..766c78e 100644 --- a/webview-ui/src/components/mcp/McpResourceRow.tsx +++ b/webview-ui/src/components/mcp/McpResourceRow.tsx @@ -5,8 +5,8 @@ type McpResourceRowProps = { } const McpResourceRow = ({ item }: McpResourceRowProps) => { - const isTemplate = "uriTemplate" in item - const uri = isTemplate ? item.uriTemplate : item.uri + const hasUri = "uri" in item + const uri = hasUri ? item.uri : item.uriTemplate return (
{ // Convert template to regex pattern - const pattern = template.uriTemplate - // Replace {param} with ([^/]+) to match any non-slash characters - .replace(/\{([^}]+)\}/g, "([^/]+)") - // Escape special regex characters except the ones we just added + const pattern = String(template.uriTemplate) + // First escape special regex characters .replace(/[.*+?^${}()|[\]\\]/g, "\\$&") - // Un-escape the capturing groups we added - .replace(/\\\(/g, "(") - .replace(/\\\)/g, ")") + // Then replace {param} with ([^/]+) to match any non-slash characters + // We need to use \{ and \} because we just escaped them + .replace(/\\\{([^}]+)\\\}/g, "([^/]+)") const regex = new RegExp(`^${pattern}$`) return regex.test(uri)