testPagesHoldAtsAndDots
tcmts.cli.web.testPagesHoldAtsAndDots · #hizcvztp · term
import { isPageRequest } from "#codebase/tcmts/cli/web";
import type http from "node:http";
export const testPagesHoldAtsAndDots = () => {
const page = (url: string, accept = "text/html,*/*") =>
isPageRequest({ url, method: "GET", headers: { accept } } as unknown as http.IncomingMessage);
for (const url of [
"/",
"/libraries",
"/@alice.dev",
"/@alice.dev/geo/1.2.0",
"/@a.dev/geo/changes/1.0.0...1.1.0",
"/x?q=a.b",
])
if (!page(url)) throw new Error(`${url} is a page`);
for (const url of [
"/@vite/client",
"/@id/x",
"/@fs/a/b.ts",
"/__tcm/rpc/x",
"/app.js",
"/icon.PNG",
"/site.webmanifest",
])
if (page(url)) throw new Error(`${url} isn't a page`);
if (page("/", "image/*")) throw new Error("an image isn't a page");
}
uses