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

Function encodeAttributeValue

xml/_entities.ts:177–181  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

175 * @returns The encoded attribute value.
176 */
177export function encodeAttributeValue(value: string): string {
178 // Fast path: no special characters means nothing to encode
179 if (!/[<>&'"\t\n\r]/.test(value)) return value;
180 return value.replace(ATTR_ENCODE_REGEXP, (c) => ATTR_ENTITY_MAP[c]!);
181}

Callers 2

serializeElementFunction · 0.90
_entities_test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected