(cr: CommandResult)
| 1323 | * misses when the body has already been JSON-stringified. |
| 1324 | */ |
| 1325 | export function buildCommandResponse(cr: CommandResult): Response { |
| 1326 | const contentType = cr.json ? 'application/json' : 'text/plain'; |
| 1327 | const safeBody = typeof cr.result === 'string' ? sanitizeBody(cr.result, !!cr.json) : cr.result; |
| 1328 | return new Response(safeBody, { |
| 1329 | status: cr.status, |
| 1330 | headers: { 'Content-Type': contentType, ...cr.headers }, |
| 1331 | }); |
| 1332 | } |
| 1333 | |
| 1334 | /** HTTP wrapper — converts CommandResult to Response. Used by the /command |
| 1335 | * route dispatcher (line ~2158). The wrapper layer exists so |
no test coverage detected