MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / validatesHeuristicEncoding

Function validatesHeuristicEncoding

src/pkg/utils/encoding.ts:277–285  ·  view source on GitHub ↗
(encoding: string, data: Uint8Array)

Source from the content-addressed store, hash-verified

275}
276
277const validatesHeuristicEncoding = (encoding: string, data: Uint8Array): boolean => {
278 try {
279 const sample = data.subarray(0, Math.min(HEURISTIC_VALIDATE_LIMIT, data.length));
280 const decoded = bytesDecode(encoding, sample);
281 return !hasSuspiciousDecodedControlChars(decoded);
282 } catch {
283 return false;
284 }
285};
286
287/**
288 * Reads a Blob or File or Uint8Array with reasonably good encoding detection

Callers 1

readRawContentFunction · 0.85

Calls 2

bytesDecodeFunction · 0.85

Tested by

no test coverage detected