Skip to content

Commit

Permalink
fix: remove specific handling of cookies in curl command
Browse files Browse the repository at this point in the history
  • Loading branch information
boiln committed Jan 25, 2025
1 parent c34cc77 commit 02452d1
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/lib/toCurl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export function toCurl(item: BurpItem): string {
const requestLines = item.request.decodedValue.split("\n");
const headers: Record<string, string> = {};
let bodyStartIndex = -1;
let cookieHeader = "";

// Skip the first line as it's the request line
for (let i = 1; i < requestLines.length; i++) {
Expand All @@ -23,17 +22,11 @@ export function toCurl(item: BurpItem): string {
if (name && valueParts.length > 0) {
const headerName = name.trim();
const headerValue = valueParts.join(":").trim();

// Handle cookies separately
if (headerName.toLowerCase() === "cookie") {
cookieHeader = headerValue;
} else {
headers[headerName] = headerValue;
}
headers[headerName] = headerValue;
}
}

// Add headers to curl command (excluding Cookie header as we'll handle it separately)
// Add all headers to curl command including Cookie header
const headerParts: string[] = [];
for (const [name, value] of Object.entries(headers)) {
headerParts.push(`-H $'${name}: ${value}'`);
Expand All @@ -42,11 +35,6 @@ export function toCurl(item: BurpItem): string {
curl_parts.push(headerParts.join(" "));
}

// Add cookies in a single -b flag if they exist
if (cookieHeader) {
curl_parts.push(`-b $'${cookieHeader}'`);
}

// Handle request body if it exists
if (bodyStartIndex !== -1) {
const body = requestLines.slice(bodyStartIndex).join("\n").trim();
Expand Down

0 comments on commit 02452d1

Please sign in to comment.