turva-llms-txt-validator 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,7 +28,7 @@ The target has to be a public domain name: an IP literal, a bracketed IPv6 addre
28
28
  |---|-------|------|------|
29
29
  | 1 | File exists at /llms.txt, HTTP 200 (a same-site www/apex redirect is followed) | non-200, or an off-site or unsafe redirect | |
30
30
  | 2 | Response is plain text | body looks like HTML | content-type is not text/plain or text/markdown |
31
- | 3 | Starts with a single H1 title | first non-empty line is not a markdown H1 | |
31
+ | 3 | Starts with an H1 title | first non-empty line is not a markdown H1 | |
32
32
  | 4 | Blockquote summary after the title | | missing one-line summary |
33
33
  | 5 | H2 sections group the content | | no H2 sections |
34
34
  | 6 | Markdown links an agent can follow | | no links, or relative links |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turva-llms-txt-validator",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Validate a site's llms.txt structure: eight checks, pass/warn/fail, JSON output. Same checks as the hosted validator at turva.dev/llms-txt-validator.",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
package/src/index.mjs CHANGED
@@ -41,10 +41,14 @@ export async function fetchLlmsTxt(host, opts = {}) {
41
41
  const reqApex = host.startsWith("www.") ? host.slice(4) : host;
42
42
  let url = "https://" + host + "/llms.txt";
43
43
  let redirectedFrom = null;
44
+ // One budget for the whole redirect chain, not one per hop. Mirrors the hosted validator
45
+ // (turva.dev/llms-txt-validator), which is canonical: with five hops a per-hop signal made
46
+ // the caller's timeout five times longer than the value it passed in.
47
+ const deadline = Date.now() + timeoutMs;
44
48
  for (let hop = 0; ; hop++) {
45
49
  const res = await fetch(url, {
46
50
  redirect: "manual",
47
- signal: AbortSignal.timeout(timeoutMs),
51
+ signal: AbortSignal.timeout(Math.max(1, deadline - Date.now())),
48
52
  headers: { "user-agent": opts.userAgent ?? UA, "accept": "text/plain, text/markdown;q=0.9, */*;q=0.1" }
49
53
  });
50
54
  if (res.status >= 300 && res.status < 400) {