Skip to the content

Capsid menu

app/components/site-speculation.tsx

12 lines and 1 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.

Functions

The functions of site-speculation.tsx
FunctionLinesComplexityCoveredCRAPMutation
SiteSpeculation10 to 151No data: no coverage report in this mapNo data: no coverage report in this mapNo data: no mutants in this code

Imports

It imports app/lib/speculation.mjs. Imported by app/components/site-header.tsx.

Source

import { useLocation } from "react-router";

import { buildSpeculationRules } from "~/lib/speculation.mjs";

// No nonce: `script-src` admits the block by the hash of these exact rules, which the Worker
// computes per response from the request's pathname with the same builder (workers/csp.mjs). So
// the pathname here must stay `useLocation().pathname`, and the text must stay raw. A refused block
// fails silently. JSON-LD is not gated by `script-src` at all.
// Chrome will not prerender with CDP attached, so no gate can assert what activation did.
export function SiteSpeculation() {
  const { pathname } = useLocation();
  const rules = buildSpeculationRules({ pathname });

  return <script type="speculationrules" dangerouslySetInnerHTML={{ __html: rules }} />;
}