mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
[autofix.ci] apply automated fixes
This commit is contained in:
@@ -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", .{});
|
||||
|
||||
|
||||
@@ -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>");
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user