changes
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import curlResponse from "../src/curl-response.ts";
|
||||
|
||||
interface PagesContext {
|
||||
request: Request;
|
||||
next(): Promise<Response>;
|
||||
}
|
||||
|
||||
export function onRequest(context: PagesContext): Response | Promise<Response> {
|
||||
const { request } = context;
|
||||
const userAgent = request.headers.get("user-agent") ?? "";
|
||||
const accept = request.headers.get("accept") ?? "";
|
||||
const isCommandLineClient =
|
||||
/^curl(?:\/|$)/i.test(userAgent) || accept.trim() === "*/*";
|
||||
|
||||
if (request.method === "GET" && isCommandLineClient) {
|
||||
return curlResponse();
|
||||
}
|
||||
|
||||
return context.next();
|
||||
}
|
||||
Reference in New Issue
Block a user