MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / extractMetaContent

Function extractMetaContent

sdk/src/tools/read-url.ts:157–175  ·  view source on GitHub ↗
(html: string, name: string)

Source from the content-addressed store, hash-verified

155}
156
157function extractMetaContent(html: string, name: string): string | undefined {
158 const escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
159 const patterns = [
160 new RegExp(
161 `<meta\\b(?=[^>]*(?:name|property)=["']${escapedName}["'])(?=[^>]*content=["']([^"']*)["'])[^>]*>`,
162 'i',
163 ),
164 new RegExp(
165 `<meta\\b(?=[^>]*content=["']([^"']*)["'])(?=[^>]*(?:name|property)=["']${escapedName}["'])[^>]*>`,
166 'i',
167 ),
168 ]
169
170 for (const pattern of patterns) {
171 const match = html.match(pattern)
172 if (match?.[1]) return normalizeText(decodeHtmlEntities(match[1]))
173 }
174 return undefined
175}
176
177function extractHtml(html: string): {
178 title?: string

Callers 1

extractHtmlFunction · 0.85

Calls 2

normalizeTextFunction · 0.85
decodeHtmlEntitiesFunction · 0.85

Tested by

no test coverage detected