@maschinenlesbar.org/ladesaeulenregister-cli
    Preparing search index...

    Function decodeBody

    • Decode a response body by the charset its Content-Type names (UTF-8 when it names none). TextDecoder drops a leading byte order mark, which Buffer#toString keeps and JSON.parse then rejects, so a BOM added by a proxy or a backend change cannot turn a valid answer into a parse error, and a Latin-1 body keeps its umlauts ("München"). An unknown charset label is a LadesaeulenParseError naming request (<METHOD> <url>, as RequestEngine.describeRequest gives it). Bytes that are not valid in the charset become U+FFFD, and replaced counts them: exactly for UTF-8 and the single-byte charsets; for UTF-16 a U+FFFD the server sent counts too. scrub (the engine passes its scrub of the base URL's credentials) runs on the charset a refusal quotes, before it is cleaned and cut.

      Parameters

      • body: Buffer
      • contentType: string
      • request: string
      • scrub: (text: string) => string = ...

      Returns { replaced: number; text: string }