MCPcopy
hub / github.com/lissy93/web-check / txtRecordHandler

Function txtRecordHandler

api/txt-records.js:5–19  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

3import { parseTarget } from './_common/parse-target.js';
4
5const txtRecordHandler = async (url) => {
6 const { hostname } = parseTarget(url);
7 const txtRecords = await dns.resolveTxt(hostname);
8 // Join chunks (DNS splits long records at 255 bytes), then key=value
9 const result = {};
10 for (const chunks of txtRecords) {
11 const full = chunks.join('');
12 const eq = full.indexOf('=');
13 let key = eq > 0 ? full.slice(0, eq) : full;
14 const val = eq > 0 ? full.slice(eq + 1) : '';
15 while (key in result) key += '_';
16 result[key] = val;
17 }
18 return result;
19};
20
21export const handler = middleware(txtRecordHandler);
22export default handler;

Callers

nothing calls this directly

Calls 1

parseTargetFunction · 0.90

Tested by

no test coverage detected