MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / decodeHtmlEntities

Function decodeHtmlEntities

server/src/routes/content.ts:1176–1187  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

1174
1175 // Decode HTML entities helper
1176 const decodeHtmlEntities = (text: string): string => {
1177 // &amp; must be decoded last to avoid double-decoding (e.g. &amp;lt; -> &lt; -> <)
1178 return text
1179 .replace(/&lt;/g, '<')
1180 .replace(/&gt;/g, '>')
1181 .replace(/&quot;/g, '"')
1182 .replace(/&#39;/g, "'")
1183 .replace(/&nbsp;/g, ' ')
1184 .replace(/&#(\d+);/g, (_, dec) => String.fromCharCode(dec))
1185 .replace(/&#x([0-9A-Fa-f]+);/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
1186 .replace(/&amp;/g, '&');
1187 };
1188
1189 // Determine title (prefer og:title, then <title>)
1190 let title = ogTitleMatch?.[1] || titleMatch?.[1] || '';

Callers 7

decodeArticleFunction · 0.70
createLatestRouterFunction · 0.70
fetchUrlMetadataFunction · 0.70
createContentRouterFunction · 0.70
createAdminFeedsRouterFunction · 0.50
fetchFeedFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected