MCPcopy
hub / github.com/callstack/agent-device / decodeXmlEntities

Function decodeXmlEntities

src/utils/xml.ts:324–344  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

322}
323
324function decodeXmlEntities(value: string): string {
325 return value.replace(
326 /&(#x[0-9a-fA-F]+|#[0-9]+|amp|lt|gt|quot|apos);/g,
327 (entity, body: string) => {
328 switch (body) {
329 case 'amp':
330 return '&';
331 case 'lt':
332 return '<';
333 case 'gt':
334 return '>';
335 case 'quot':
336 return '"';
337 case 'apos':
338 return "'";
339 default:
340 return decodeNumericXmlEntity(entity, body);
341 }
342 },
343 );
344}
345
346function decodeNumericXmlEntity(entity: string, body: string): string {
347 const codePoint = body.startsWith('#x')

Callers 2

appendTextMethod · 0.85
readAttributeValueMethod · 0.85

Calls 1

decodeNumericXmlEntityFunction · 0.70

Tested by

no test coverage detected