Files
openclaw/src/test-helpers/http.ts
2026-03-13 20:19:39 +00:00

21 lines
529 B
TypeScript

export function jsonResponse(body: unknown, status = 200): Response {
return new Response(JSON.stringify(body), {
status,
headers: { "Content-Type": "application/json" },
});
}
export function requestUrl(input: string | URL | Request): string {
if (typeof input === "string") {
return input;
}
if (input instanceof URL) {
return input.toString();
}
return input.url;
}
export function requestBodyText(body: BodyInit | null | undefined): string {
return typeof body === "string" ? body : "{}";
}