MCPcopy Create free account
hub / github.com/codeaashu/claude-code / parseSearchResults

Function parseSearchResults

web/components/tools/ToolWebSearch.tsx:23–41  ·  view source on GitHub ↗
(result: string)

Source from the content-addressed store, hash-verified

21}
22
23function parseSearchResults(result: string): SearchResult[] {
24 // Try JSON first
25 try {
26 const data = JSON.parse(result);
27 if (Array.isArray(data)) {
28 return data.map((item) => ({
29 title: item.title ?? item.name ?? "(no title)",
30 url: item.url ?? item.link ?? "",
31 snippet: item.snippet ?? item.description ?? item.content ?? "",
32 }));
33 }
34 if (data.results) return parseSearchResults(JSON.stringify(data.results));
35 } catch {
36 // not JSON
37 }
38
39 // Fallback: treat raw text as a single result
40 return [{ title: "Search Result", url: "", snippet: result }];
41}
42
43export function ToolWebSearch({
44 input,

Callers 1

ToolWebSearchFunction · 0.70

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected