mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-19 18:04:48 +00:00
* Add lefthook formatter checks * Fix SDK mode hydration * Stabilize SDK mode integration test
13 lines
524 B
TypeScript
13 lines
524 B
TypeScript
import { escapeSingleQuotes } from "./format";
|
|
|
|
export const buildCurl = (method: string, url: string, body?: string, token?: string) => {
|
|
const headers: string[] = [];
|
|
if (token) {
|
|
headers.push(`-H 'Authorization: Bearer ${escapeSingleQuotes(token)}'`);
|
|
}
|
|
if (body) {
|
|
headers.push(`-H 'Content-Type: application/json'`);
|
|
}
|
|
const data = body ? `-d '${escapeSingleQuotes(body)}'` : "";
|
|
return `curl -X ${method} ${headers.join(" ")} ${data} '${escapeSingleQuotes(url)}'`.replace(/\s+/g, " ").trim();
|
|
};
|