UNPKG

@stacksjs/router

Version:
12 lines (11 loc) 406 B
export const JSON_CONTENT_TYPE = /^application\/(?:json|.+\+json)(?:;|$)/i; export function isApiRequest(req) { const headers = req.headers, contentType = headers.get("content-type") || ""; if (JSON_CONTENT_TYPE.test(contentType)) return !0; if (headers.get("sec-fetch-dest") === "document") return !1; if ((headers.get("accept") || "").includes("text/html")) return !1; return !0; }