MCPcopy Create free account
hub / github.com/Effect-TS/effect / decodeText

Method decodeText

packages/effect/src/encoding/Xml.ts:1637–1650  ·  view source on GitHub ↗
(raw: string, offset: number, attribute: boolean, whitespace: boolean)

Source from the content-addressed store, hash-verified

1635 // Replaces references and normalizes line endings, or attribute whitespace.
1636 // `whitespace` is false when `raw` has nothing to normalize.
1637 private decodeText(raw: string, offset: number, attribute: boolean, whitespace: boolean): string {
1638 let out = ""
1639 let k = 0
1640 while (true) {
1641 const amp = raw.indexOf("&", k)
1642 const literal = raw.slice(k, amp === -1 ? raw.length : amp)
1643 out += !whitespace ? literal : attribute ? normalizeAttribute(literal) : normalizeLines(literal)
1644 if (amp === -1) return out
1645 const semicolon = raw.indexOf(";", amp + 1)
1646 if (semicolon === -1) throw this.syntax("unterminated reference", offset + amp)
1647 out += this.reference(raw, amp, semicolon, offset)
1648 k = semicolon + 1
1649 }
1650 }
1651
1652 // Decodes the reference `raw[amp, semicolon]`
1653 private reference(raw: string, amp: number, semicolon: number, offset: number): string {

Callers 15

parseMethod · 0.95
attributeValueMethod · 0.95
runFunction · 0.80
collectStreamFunction · 0.80
Core.tsFile · 0.80
WorktreesClass · 0.80
buildResponseStreamFunction · 0.80
buildResponseStreamFunction · 0.80

Calls 5

syntaxMethod · 0.95
referenceMethod · 0.95
normalizeAttributeFunction · 0.85
normalizeLinesFunction · 0.85
sliceMethod · 0.80

Tested by 1

outputFunction · 0.64