isPageRequest
A request for a page, as opposed to an asset, a module or an API call: a browser's GET for HTML, not tcm's own
routes or Vite's (/@vite/, /@id/, /@fs/), nor a file by a type tcm serves (.js, .png). A page's path can
hold @ and dots (/@alice.dev/geo/1.2.0).
import { CONTENT_TYPES } from "#codebase/tcmts/cli/web"; import type http from "node:http"; export function isPageRequest(req: http.IncomingMessage): boolean { const url = (req.url ?? "/").split("?")[0]!; const ext = /\.\w+$/.exec(url)?.[0].toLowerCase(); return ( req.method === "GET" && /text\/html/.test(req.headers.accept ?? "") && !url.startsWith("/__tcm/") && !/^\/@(vite|id|fs|react-refresh)(\/|$)/.test(url) && !(ext && ext in CONTENT_TYPES) ); }