MCPcopy Create free account
hub / github.com/angular/angular / getBestSnippetForMatch

Method getBestSnippetForMatch

adev/shared-docs/services/search.service.ts:144–162  ·  view source on GitHub ↗
(result: SearchResult)

Source from the content-addressed store, hash-verified

142 }
143
144 private getBestSnippetForMatch(result: SearchResult): string {
145 const hierarchy = result._snippetResult.hierarchy;
146 if (hierarchy === undefined) {
147 return '';
148 }
149
150 // return the most specific subheader match
151 if (matched(hierarchy.lvl4)) {
152 return hierarchy.lvl4!.value;
153 }
154 if (matched(hierarchy.lvl3)) {
155 return hierarchy.lvl3!.value;
156 }
157 if (matched(hierarchy.lvl2)) {
158 return hierarchy.lvl2!.value;
159 }
160 // if no subheader matched the query, fall back to just returning the most specific one
161 return hierarchy.lvl3?.value ?? hierarchy.lvl2?.value ?? '';
162 }
163
164 /**
165 * Returns an HTML string with marked text for the matches

Callers 1

parseResultMethod · 0.95

Calls 1

matchedFunction · 0.85

Tested by

no test coverage detected