MCPcopy Create free account
hub / github.com/denoland/std / normalizeAttributeValue

Function normalizeAttributeValue

xml/_parser.ts:38–44  ·  view source on GitHub ↗

* Normalizes attribute value per XML 1.0 §3.3.3. * * Only predefined entities are expanded (lt, gt, amp, apos, quot). * Custom entities from DTD are NOT expanded. * * @see https://www.w3.org/TR/xml/#AVNormalize

(raw: string, xml11: boolean)

Source from the content-addressed store, hash-verified

36 * @see {@link https://www.w3.org/TR/xml/#AVNormalize}
37 */
38function normalizeAttributeValue(raw: string, xml11: boolean): string {
39 // Replace literal \t and \n with space BEFORE entity decoding (preserves 
)
40 const normalized = raw.includes("\t") || raw.includes("\n")
41 ? raw.replace(/[\t\n]/g, " ")
42 : raw;
43 return decodeEntities(normalized, xml11);
44}
45
46/** Threshold above which duplicate detection switches from linear scan to Set. */
47const ATTR_SET_THRESHOLD = 32;

Callers 2

_addMethod · 0.85
onAttributeMethod · 0.85

Calls 2

decodeEntitiesFunction · 0.90
includesMethod · 0.80

Tested by

no test coverage detected