[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot]
2025-08-25 05:55:56 +00:00
committed by GitHub
parent 537459129b
commit e239dcdc54
2 changed files with 14 additions and 13 deletions

View File

@@ -2935,13 +2935,13 @@ fn encodeSerializedFailures(
/// Check if the client is likely a browser based on User-Agent header
fn isBrowserClient(req: *Request) bool {
const user_agent = req.header("user-agent") orelse return false;
// Check for common browser indicators in User-Agent string
return std.mem.indexOf(u8, user_agent, "Mozilla/") != null or
std.mem.indexOf(u8, user_agent, "Chrome/") != null or
std.mem.indexOf(u8, user_agent, "Safari/") != null or
std.mem.indexOf(u8, user_agent, "Firefox/") != null or
std.mem.indexOf(u8, user_agent, "Edge/") != null;
std.mem.indexOf(u8, user_agent, "Chrome/") != null or
std.mem.indexOf(u8, user_agent, "Safari/") != null or
std.mem.indexOf(u8, user_agent, "Firefox/") != null or
std.mem.indexOf(u8, user_agent, "Edge/") != null;
}
fn sendSerializedFailures(
@@ -3012,7 +3012,7 @@ fn sendSerializedFailures(
try buf.writer().print("{s}\n\n", .{page_title});
try buf.writer().print("Bun development server encountered an error.\n", .{});
try buf.writer().print("Found {d} error(s) preventing the application from running.\n\n", .{failures.len});
try buf.writer().print("To see detailed error information, open this URL in a web browser.\n", .{});
try buf.writer().print("For programmatic access to error details, consider using WebSocket connections.\n", .{});

View File

@@ -18,10 +18,11 @@ devTest("returns plain text errors for non-browser User-Agent (#22055)", {
// Test with browser User-Agent (should get HTML)
const browserResponse = await dev.fetch("/", {
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
}
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
},
});
expect(browserResponse.status).toBe(500);
const browserText = await browserResponse.text();
expect(browserResponse.headers.get("content-type")).toContain("text/html");
@@ -30,10 +31,10 @@ devTest("returns plain text errors for non-browser User-Agent (#22055)", {
// Test with non-browser User-Agent (should get plain text)
const fetchResponse = await dev.fetch("/", {
headers: {
"User-Agent": "fetch/1.0"
}
"User-Agent": "fetch/1.0",
},
});
expect(fetchResponse.status).toBe(500);
const fetchText = await fetchResponse.text();
expect(fetchResponse.headers.get("content-type")).toContain("text/plain");
@@ -42,4 +43,4 @@ devTest("returns plain text errors for non-browser User-Agent (#22055)", {
expect(fetchText).not.toContain("<!doctype html>");
expect(fetchText).not.toContain("<script>");
},
});
});