turva-llms-txt-validator 0.9.1 → 0.9.2

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
@@ -88,13 +88,13 @@ The validator removes C0 and C1 control characters, bidirectional controls and i
88
88
 
89
89
  With `--json`, an invalid domain or a failed fetch returns `{ "error": "...", "target": "..." }` and exits with code `2`. A network error adds `code` when the error carries one, such as `EAI_AGAIN`. An unknown option, a second domain and a missing domain return `{ "error": "..." }` only, with no target, and also exit with code `2`. `--help` and `--version` win over argument errors, also with `--json`, and exit with code `0`. An unknown option is named by its dashes and the letters, digits and dashes after them, and the rest of the argument is not shown, so a target typed with a leading dash, as in `-u:secret@example.com`, gives `unknown option "-u" (the rest of the argument is not shown)`.
90
90
 
91
- In an error report the `target` is the address given on the command line. When it parses as a URL with a host, the user name and password are removed and each query value becomes `***`. Other values follow these cases:
91
+ In an error report the `target` is the address given on the command line. A value that starts with a single slash and still holds an `@` after masking, such as `/user:secret@example.com`, is shown as `/***`, because the text is your own argument and may be user information. When it parses as a URL with a host, the user name and password are removed and each query value becomes `***`. Other values follow these cases:
92
92
 
93
93
  - In a value such as `user:secret@example.com` or `example.org:8443#a@b`, the part before the colon reads as a URL scheme and no authority follows it, so only `//***` is shown.
94
94
  - A value with no scheme and no slash is read as user information when a colon comes before its last `@` and before its first `?` or `#`. So `user_name:secret@example.com` and `user_name:se#cret@example.com` are shown as `***@example.com`. A backslash counts as part of the user name, as in a Windows domain account, so `CORP\erik:se#cret@example.com` is shown as `***@example.com` too. The same reading holds when such a value is a relative redirect target that is resolved against the request address, so the password does not come back in the path of the shown address. When the validator follows such a redirect, the address it reached is shown as its scheme, its host and `/***`, as in `https://example.com/***`, and so is an address reached after it while its `Location` keeps part of the earlier path or query. An address whose `Location` keeps none of it, such as an absolute address or a path from the root, is shown as usual. There a `?` or `#` before the last `@` shows only `***`, because the text after it could also be read as a query or a fragment. When a `?` or `#` comes before the colon, as in `user?x:secret@example.com`, the text from that character on is masked or cut, so the part before it is shown and the password is not.
95
95
  - Without that colon, as in `path@2x.png` or an e-mail address, the value is shown as given and holds no password.
96
- - An address that holds an `@` shows only `***`, with the scheme in front when a slash follows its colon and with no host, when a URL parser and a person would read it differently. That covers a backslash, a `?` or a `#` before the `@` and before any `/`, and a start that is not exactly a scheme, two slashes and a character other than a slash. `https://user:pa?ss@example.com/`, `https://example.org?e=a@b.com` and `https:///host?e=a@b.com` are shown as `https://***`. `user:secret@host.example://dd`, where no slash follows the scheme colon, is shown as `//***`. The same holds for a word that a URL parser refuses as a scheme when a slash or a backslash follows its colon, as in `my_app:/user:secret@host`, and for an address that the parser refuses when a `?` or `#` comes before its last `@`, as in `https://user:pa/ss?secret@example.com`. A redirect to such an address is reported as "a different host that this report does not name". A `/` before the `@` makes it a path, so `https://user:12/ss@example.com/` is the host `user` with the port 12 and the path `/ss@example.com/`, and it is shown as written. A relative reference such as `/a@b` or `docs/@name` is masked as before.
97
- - Spaces, C0 control characters, Unicode spaces and invisible characters such as U+200B at either end of a value are removed before it is read, so a value that starts with U+2003 before `https:/user:secret@example.com` is read as `https:/user:secret@example.com` and shown as `https://***`. The edge set follows Unicode classes: spaces, control characters, format characters and default-ignorable characters. A `Location` header reaches the validator as bytes that the platform reads as Latin-1. When those bytes form valid UTF-8, the validator reads them as UTF-8 for masking, so a U+3000 at the start of a `Location` is removed in its real form and in its byte form. A byte that is not valid UTF-8 stays as it arrived between the first and the last printable ASCII character. Before the first and after the last one it counts as an edge character. A followed address with such a byte at its edge is shown as `https://host/***`, and the address shown with a redirect refused as one hop too many leaves the byte out.
96
+ - An address that holds an `@` shows only `***`, with the scheme in front when a slash follows its colon and with no host, when a URL parser and a person would read it differently. That covers a backslash, a `?` or a `#` before the `@` and before any `/`, and a start that is not exactly a scheme, two slashes and a character other than a slash. `https://user:pa?ss@example.com/`, `https://example.org?e=a@b.com` and `https:///host?e=a@b.com` are shown as `https://***`. `user:secret@host.example://dd`, where no slash follows the scheme colon, is shown as `//***`. The same holds for a word that a URL parser refuses as a scheme when a slash or a backslash follows its colon, as in `my_app:/user:secret@host`, and for an address that the parser refuses when a `?` or `#` comes before its last `@`, as in `https://user:pa/ss?secret@example.com`. A redirect to such an address is reported as "a different host that this report does not name". A `/` before the `@` makes it a path, so `https://user:12/ss@example.com/` is the host `user` with the port 12 and the path `/ss@example.com/`, and it is shown as written. A relative reference such as `docs/@name` is shown as given, and one that starts with a single slash, such as `/a@b`, is shown as `/***`.
97
+ - Spaces, C0 control characters, Unicode spaces and invisible characters such as U+200B at either end of a value are removed before it is read, so a value that starts with U+2003 before `https:/user:secret@example.com` is read as `https:/user:secret@example.com` and shown as `https://***`. The edge set follows Unicode classes: spaces, control characters, format characters and default-ignorable characters, plus U+0085, U+180E, U+200B, U+2800 and U+FFFD. A `Location` header reaches the validator as bytes that the platform reads as Latin-1. When those bytes form valid UTF-8, the validator reads them as UTF-8 for masking and for resolving the address it follows. The bytes of `/caf` followed by C3 A9 are requested as `/caf%C3%A9`. Because the bytes are read as UTF-8 for masking, a U+3000 at the start of a `Location` is removed in its real form and in its byte form. A byte that is not valid UTF-8 stays as it arrived between the first and the last printable ASCII character. Before the first and after the last one it counts as an edge character. A followed address with such a byte at its edge is shown as `https://host/***`, and the address shown with a redirect refused as one hop too many leaves the byte out.
98
98
  - Text before `://` that a URL parser does not accept as a scheme, such as `my_app://user:secret@host/p`, `1app://user:secret@host/p` or `ht tps://user:secret@host/p`, is masked from the text: everything up to the last `@` is shown as `***`.
99
99
 
100
100
  ## What it checks
@@ -156,7 +156,7 @@ These checks are labelled **v2** in the output. They look for link relations in
156
156
 
157
157
  | # | Check | Pass condition | Otherwise |
158
158
  | --- | --- | --- | --- |
159
- | 9 | Home page points to its llms.txt | `rel="describedby"` has a non-empty target | `info` |
159
+ | 9 | Home page points to its llms.txt | `rel="describedby"` has a target that is not empty, not made only of white space or invisible characters and not a bare fragment such as `#top` | `info` |
160
160
  | 10 | Home page points to a Markdown version | `rel="alternate"` has media type `text/markdown` and a non-empty target | `info` |
161
161
 
162
162
  The validator detects these declarations without fetching their targets. It reads the first 65,536 UTF-16 code units of the head after comments and the contents of script, style, title, noscript, noframes and template elements have been set aside. When a relation is missing from a longer head, the result says that only that part was read. Inside a script, `<!-->` and `<!--->` end the comment escape at once, as the HTML tokenizer reads them, and a `<template>` inside `<svg>` or `<math>` is an ordinary element that opens no template level. Until 0.8.0 both shapes made the scan skip a relation that the parser puts in the head, or read one that it moves into the body.
@@ -232,7 +232,7 @@ The default validation requests two documents: `https://<host>/llms.txt` and `ht
232
232
  - Timeout: eight seconds per document, shared across its redirect chain.
233
233
  - Read limit: 256 KiB, which is 262,144 bytes, per response by default. A file cut there gets the size note "over 256 KiB, read truncated". A library caller can change the limit, see the options above.
234
234
  - Redirects: up to four hops, over HTTPS, to the same host or its `www`/apex equivalent. Off-site redirects, embedded credentials and unsupported ports are rejected. A redirect target is reported with its credentials and fragment removed and its query values masked, whether the redirect was followed or rejected. A result names a redirect target in the `location` field, in the sentences about another host and an unsupported target, and in the address a followed redirect reached. The sentences about too many redirects and an unusable `Location` name no target.
235
- - Host checks: IP literals, bracketed IPv6 addresses, localhost and the internal-use TLDs `localdomain`, `local`, `internal`, `home`, `lan`, `corp`, `test`, `invalid`, `arpa` and `onion` are rejected before a request is sent. An address that holds `@`, `?` or `#` is not repeated in the error message, because it can carry a user name, a password or a query value. The message names the host that a URL parser reads from such an address only when that host is the text right after the last `@`, or when the address holds no `@`. So `//user?@example.com`, where the parser reads the user name as the host, names no host. The address `//user.example?@example.com` is accepted as the host `user.example`, because a URL parser ends the host at the `?`. It requests that host and shows it as the target. One trailing dot on the host you give, as in `example.com.`, is removed first. Redirect targets are checked too, and one trailing dot on a redirect target is removed the same way.
235
+ - Host checks: IP literals, bracketed IPv6 addresses, localhost and the internal-use TLDs `localdomain`, `local`, `internal`, `home`, `lan`, `corp`, `test`, `invalid`, `arpa` and `onion` are rejected before a request is sent. An address that holds `@`, `?` or `#` is not repeated in the error message, because it can carry a user name, a password or a query value. Any other address is repeated with control, bidirectional and invisible characters removed. The message names the host that a URL parser reads from such an address only when that host is the whole text right after the last `@`, up to a port, a path, a query or a fragment, or when the address holds no `@`. So `//user?@example.com`, where the parser reads the user name as the host, names no host. The address `//user.example?@example.com` is accepted as the host `user.example`, because a URL parser ends the host at the `?`. It requests that host and shows it as the target. One trailing dot on the host you give, as in `example.com.`, is removed first. Redirect targets are checked too, and one trailing dot on a redirect target is removed the same way.
236
236
 
237
237
  **DNS resolution is not checked for private addresses.** A syntactically public domain can resolve to a private IP, so if you expose this package through a service that accepts untrusted domains, enforce private-address restrictions at the network layer. Local and CI runs use their own network policy. The hosted validator runs on the Cloudflare edge.
238
238
 
@@ -255,12 +255,12 @@ The strict type check found two inputs that could leave `undefined` in a check's
255
255
  GitHub Actions publishes every version from 0.1.3 on with npm trusted publishing, and each one carries a provenance attestation. To check one, install it in an empty directory and ask npm to verify the signatures. Replace the version with the one you want to check.
256
256
 
257
257
  ```sh
258
- mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.9.1 --ignore-scripts && npm audit signatures
258
+ mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.9.2 --ignore-scripts && npm audit signatures
259
259
  ```
260
260
 
261
261
  `npm audit signatures` checks the registry signature and the provenance attestation of each installed package that has one. The attestation of this package names three things to compare with what you expect: the repository, the workflow file `.github/workflows/publish.yml` and the commit that produced the tarball. Versions up to and including 0.8.4 were built in `github.com/erekola/llms-txt-validator`, before the repository moved to the turva-dev organization on 2026-11-25. Every later release is built in `github.com/turva-dev/llms-txt-validator`. The npm version page shows them under Provenance.
262
262
 
263
- Tag `v0.9.1` must point at that same commit, and `gh api repos/turva-dev/llms-txt-validator/commits/v0.9.1 --jq .sha` prints it. A mismatch is a reason not to use that version. Provenance proves which workflow built a release and from which commit. It does not prove that the code is safe, so reading the source and the dependencies stays your job.
263
+ Tag `v0.9.2` must point at that same commit, and `gh api repos/turva-dev/llms-txt-validator/commits/v0.9.2 --jq .sha` prints it. A mismatch is a reason not to use that version. Provenance proves which workflow built a release and from which commit. It does not prove that the code is safe, so reading the source and the dependencies stays your job.
264
264
 
265
265
  ## Development
266
266
 
package/dist/bin/cli.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // curl -H "Accept: application/json" "https://turva.dev/llms-txt-validator?url=example.com"
8
8
  import { readFileSync } from "node:fs";
9
9
  import { fileURLToPath } from "node:url";
10
- import { validateHost, stripControls, maskLocation } from "../src/index.js";
10
+ import { validateHost, stripControls, maskTypedTarget } from "../src/index.js";
11
11
  const USAGE = [
12
12
  "usage: llms-txt-validate <domain-or-url> [--json] [--strict]",
13
13
  " --json print the result as JSON (same shape as the hosted validator for a completed validation)",
@@ -97,7 +97,7 @@ catch (err) {
97
97
  // a password or a query value typed into the command line is never echoed back.
98
98
  const code = (err && err.cause && err.cause.code) || (err && err.code);
99
99
  if (json) {
100
- const report = { error: message, target: stripControls(maskLocation(targets[0])) };
100
+ const report = { error: message, target: maskTypedTarget(targets[0]) };
101
101
  if (code)
102
102
  report.code = stripControls(String(code));
103
103
  console.log(JSON.stringify(report, null, 2));
@@ -52,6 +52,7 @@ export declare function stripBidi(s: unknown): string;
52
52
  export declare function stripControls(s: unknown): string;
53
53
  export declare function normalizeHostInput(raw: unknown): string | null;
54
54
  export declare function enteredPath(raw: unknown): string;
55
+ export declare function maskTypedTarget(raw: string): string;
55
56
  export declare function isValidPublicHost(host: string | null | undefined): boolean;
56
57
  export declare function fetchLlmsTxt(host: string, opts?: FetchOptions): Promise<FetchedLlmsTxt | FetchRedirect>;
57
58
  export declare function validateLlmsTxt(f: LlmsTxtInput): LlmsCheck[];
package/dist/src/index.js CHANGED
@@ -431,7 +431,49 @@ export function enteredPath(raw) {
431
431
  function typedHostEcho(raw) {
432
432
  const host = normalizeHostInput(raw) || "";
433
433
  const at = raw.lastIndexOf("@");
434
- return host && (at < 0 || raw.slice(at + 1).toLowerCase().startsWith(host)) ? host : "";
434
+ // The text after the last @ has to be the parsed host in full: the host is followed by the end of the text, a port, a path,
435
+ // a query, a fragment or a backslash, once with one trailing dot in between. A bare prefix match named the user name of
436
+ // "//admin?@admin.example.com" as "admin" (K12 of the Antigravity review, 2026-12-01). Mirrors worker.ts echoHostEnds().
437
+ return host && (at < 0 || echoHostEnds(raw.slice(at + 1).toLowerCase(), host)) ? host : "";
438
+ }
439
+ function echoHostEnds(rest, host) {
440
+ if (!rest.startsWith(host))
441
+ return false;
442
+ let next = rest.slice(host.length);
443
+ if (next.startsWith("."))
444
+ next = next.slice(1);
445
+ return next === "" || /^[:\/?#\\]/.test(next);
446
+ }
447
+ // A Location value reaches this code as one code unit per byte. When those bytes are valid UTF-8 text with at least one
448
+ // non-ASCII byte, the address is read from the text, as a browser does and as markdown-parity-check has done since 0.2.43:
449
+ // "/caf" + the bytes C3 A9 resolves to /caf%C3%A9 and not to the double-encoded /caf%C3%83%C2%A9 (K13 of the Antigravity
450
+ // review, 2026-12-01). Any other value is returned as it arrived. Mirrors worker.ts locationAsUtf8().
451
+ function locationAsUtf8(raw) {
452
+ let high = false;
453
+ for (let i = 0; i < raw.length; i++) {
454
+ const c = raw.charCodeAt(i);
455
+ if (c > 0xff)
456
+ return raw;
457
+ if (c > 0x7f)
458
+ high = true;
459
+ }
460
+ if (!high)
461
+ return raw;
462
+ try {
463
+ return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(Uint8Array.from(raw, (ch) => ch.charCodeAt(0)));
464
+ }
465
+ catch {
466
+ return raw;
467
+ }
468
+ }
469
+ // The address a --json error report names as its target (K11 of the Antigravity review, 2026-12-01). It is the address
470
+ // typed on the command line, masked like every address the tool prints. A relative reference that still holds an "@" after
471
+ // masking, such as "/user:secret@host", is shown as "/***": maskLocation keeps it as a path for a Location header
472
+ // (decision Tek-898), but here the text is the user's own argument and may be user information. Every other form keeps
473
+ // the masked text maskLocation gives.
474
+ export function maskTypedTarget(raw) {
475
+ const shown = stripInvisible(stripControls(stripBidi(maskLocation(raw))));
476
+ return shown.includes("@") && /^\/(?!\/)/.test(shown) ? "/***" : shown;
435
477
  }
436
478
  export function isValidPublicHost(host) {
437
479
  if (!host || host.length > 253)
@@ -533,13 +575,14 @@ export async function fetchLlmsTxt(host, opts = {}) {
533
575
  catch { /* the verdict below is the answer */ }
534
576
  const loc = res.headers.get("location") || "";
535
577
  const shown = headerText(loc);
578
+ const locUrl = locationAsUtf8(loc);
536
579
  if (!loc)
537
580
  return { redirect: true, reason: "no-location", status: res.status, location: "" };
538
581
  if (hop >= 4)
539
582
  return { redirect: true, reason: "too-many", status: res.status, location: cut(maskLocation(shown, hidden ? undefined : url), 120) };
540
583
  let next;
541
584
  try {
542
- next = new URL(loc, url);
585
+ next = new URL(locUrl, url);
543
586
  }
544
587
  catch {
545
588
  return { redirect: true, reason: "bad-location", status: res.status, location: cut(maskLocation(shown, hidden ? undefined : url), 120) };
@@ -568,7 +611,7 @@ export async function fetchLlmsTxt(host, opts = {}) {
568
611
  // marked address did not reach it. Bases one segment deep let ".." and "../x" clear the mark while the hidden
569
612
  // segments stayed (F1 of the seventh check, 2026-11-22).
570
613
  const inheritsBase = (() => { const u0 = new URL(url); let n = 0; const alt = u0.origin + u0.pathname.replace(/[^\/]+/g, () => "zz9q" + n++) + (u0.search ? "?zz9q" : ""); try {
571
- return new URL(loc, url).href !== new URL(loc, alt).href;
614
+ return new URL(locUrl, url).href !== new URL(locUrl, alt).href;
572
615
  }
573
616
  catch {
574
617
  return true;
@@ -592,7 +635,11 @@ export async function fetchLlmsTxt(host, opts = {}) {
592
635
  truncated = true;
593
636
  chunks.push(value.slice(0, value.length - (bytes - cap)));
594
637
  bytes = cap;
595
- await reader.cancel();
638
+ // A cancel that throws must not turn a read that already hit the cap into a network error (K45 of the Antigravity review).
639
+ try {
640
+ await reader.cancel();
641
+ }
642
+ catch { /* the cap is the answer */ }
596
643
  break;
597
644
  }
598
645
  chunks.push(value);
@@ -941,7 +988,7 @@ function collectLinkDefinitions(text, lineBlocks, defAt) {
941
988
  offset += l.length + 1;
942
989
  }
943
990
  }
944
- let prevDef = false, prevQuote = 0, prevInner = "";
991
+ let prevDef = false, prevQuote = 0, prevInner = "", titleLine = -1;
945
992
  for (let i = 0; i < lines.length; i++) {
946
993
  const line = lines[i];
947
994
  const qm = quoteMarkers(line);
@@ -955,6 +1002,12 @@ function collectLinkDefinitions(text, lineBlocks, defAt) {
955
1002
  prevDef = false;
956
1003
  prevQuote = qm.quote;
957
1004
  prevInner = inner;
1005
+ // The title of the definition above, written alone on this line, belongs to that definition, so the line after it still
1006
+ // opens a definition (K18a of the Antigravity review, 2026-12-01).
1007
+ if (i === titleLine) {
1008
+ prevDef = true;
1009
+ continue;
1010
+ }
958
1011
  let opens;
959
1012
  if (i === 0 || wasDef || qm.quote > before)
960
1013
  opens = true;
@@ -979,6 +1032,12 @@ function collectLinkDefinitions(text, lineBlocks, defAt) {
979
1032
  if (!label)
980
1033
  continue;
981
1034
  prevDef = true;
1035
+ if (!m[3] && i + 1 < lines.length) {
1036
+ const nextLine = lines[i + 1];
1037
+ const nextMarks = quoteMarkers(nextLine);
1038
+ if (/^[ \t]*(?:"[^"\n]*"|'[^'\n]*'|\([^()\n]*\))[ \t]*$/.test(nextLine.slice(nextMarks.at)) && nextMarks.quote === qm.quote)
1039
+ titleLine = i + 1;
1040
+ }
982
1041
  if (defAt)
983
1042
  defAt.add(bracketAt);
984
1043
  if (defs.has(label))
@@ -1190,8 +1249,17 @@ function collectLinks(text, defs, lineBlocks) {
1190
1249
  stack.push(k);
1191
1250
  else if (c === "]") {
1192
1251
  const o = stack.pop();
1193
- if (o !== undefined)
1252
+ if (o !== undefined) {
1194
1253
  pairs[o] = k;
1254
+ // The destination and the title of an inline link or image are no bracket text: a "]" in "![i](x.png "fig ]1")" or a
1255
+ // "[" in "(x.png?x=[1)" would otherwise close or open a pair of the outer link text (K14 of the Antigravity review,
1256
+ // 2026-12-01). A target that does not parse is left as it is.
1257
+ if (text[k + 1] === "(") {
1258
+ const t = readTarget(k + 2);
1259
+ if (t)
1260
+ k = t.end;
1261
+ }
1262
+ }
1195
1263
  }
1196
1264
  else if (c === "\n" && blankAt(k))
1197
1265
  stack.length = 0;
@@ -1720,6 +1788,17 @@ function blankCodeForHtml(prose, lineBlocks) {
1720
1788
  const c = prose[i];
1721
1789
  out.push(c !== "\n" && (mask[i] === 1 || ((c === "<" || c === ">") && isEscaped(prose, i))) ? " " : c);
1722
1790
  }
1791
+ // A link destination in angle brackets, "[Guide](<guide (1).md>)" or "[Guide](<api>)", is no HTML tag, and the README
1792
+ // recommends the form (K15 of the Antigravity review, 2026-12-01). Only a destination that is followed by the end of
1793
+ // the link, ")" or a title, is blanked, so "](<b>bold</b>" stays a tag.
1794
+ const angleDestination = /\]\([ \t]*(<[^<>\n]*>)(?=[ \t]*(?:\)|["'(]))/g;
1795
+ for (let m = angleDestination.exec(prose); m; m = angleDestination.exec(prose)) {
1796
+ if (mask[m.index] === 1 || isEscaped(prose, m.index))
1797
+ continue;
1798
+ const s = m.index + m[0].length - m[1].length;
1799
+ for (let k = s; k < s + m[1].length; k++)
1800
+ out[k] = " ";
1801
+ }
1723
1802
  return out.join("");
1724
1803
  }
1725
1804
  // List lines that look like a link entry and are not one (Tek-730, 2026-10-31). Two measured
@@ -1909,7 +1988,15 @@ export function validateLlmsTxt(f) {
1909
1988
  else {
1910
1989
  add("h1-title", "fail", "Starts with an H1 title", "the first non-empty line should be a markdown H1 (# Site name, or one line of text underlined with =)");
1911
1990
  }
1912
- const afterIdx = lines.findIndex((l, i) => i > h1End && !isMdBlank(l));
1991
+ let afterIdx = lines.findIndex((l, i) => i > h1End && !isMdBlank(l));
1992
+ // A file whose first line opens a code fence or a raw HTML block has no title, and what stands inside that block is no
1993
+ // summary: the lines of the block are skipped (K17 of the Antigravity review, 2026-12-01).
1994
+ if (firstIdx !== -1 && title === null && !setext) {
1995
+ const startBlocks = readBlocks(lines);
1996
+ const startHtml = htmlBlockLines(lines, startBlocks);
1997
+ if (startBlocks[h1End] < 0 || startHtml[h1End])
1998
+ afterIdx = lines.findIndex((l, i) => i > h1End && !isMdBlank(l) && startBlocks[i] >= 0 && !startHtml[i]);
1999
+ }
1913
2000
  const afterH1 = afterIdx === -1 ? "" : lines[afterIdx];
1914
2001
  // Read the same way as the H1 check and the "late" blockquote search below: at most three
1915
2002
  // leading spaces, per CommonMark. A trim-first prefix test used to erase the difference, so
@@ -3370,6 +3457,13 @@ function describesOtherResource(anchor, homeUrls) {
3370
3457
  return false;
3371
3458
  } });
3372
3459
  }
3460
+ // A relation target that points nowhere names no file: it is empty, holds only white space or characters a reader does not
3461
+ // see (a no-break space from "&nbsp;"), or is a bare fragment, which stays on the page that carries it (K16 of the
3462
+ // Antigravity review, 2026-12-01). Such a target is no relation. Mirrors worker.ts pointsNowhere().
3463
+ function pointsNowhere(href) {
3464
+ const t = trimEnds(href, isUrlEdge);
3465
+ return t === "" || t[0] === "#";
3466
+ }
3373
3467
  export function findLinkRelations(html, linkHeader, readCut = false, homeUrls = []) {
3374
3468
  const found = { describedby: null, markdown: null };
3375
3469
  // Only the head, and only what a parser would put there: a commented-out link element,
@@ -3401,7 +3495,7 @@ export function findLinkRelations(html, linkHeader, readCut = false, homeUrls =
3401
3495
  // text/markdown, not anything that starts with it, and a relation without a target is
3402
3496
  // not a relation: both passed until 2026-08-29.
3403
3497
  const isMarkdown = trimChars(type.split(";")[0], HTTP_WHITESPACE) === "text/markdown";
3404
- if (!found.describedby && href && rel.includes("describedby"))
3498
+ if (!found.describedby && href && !pointsNowhere(href) && rel.includes("describedby"))
3405
3499
  found.describedby = href;
3406
3500
  if (!found.markdown && href && rel.includes("alternate") && isMarkdown)
3407
3501
  found.markdown = href;
@@ -3413,7 +3507,7 @@ export function findLinkRelations(html, linkHeader, readCut = false, homeUrls =
3413
3507
  const rel = trimChars(asciiLower(link.params.rel || ""), HTTP_WHITESPACE).split(/[\t\n\r ]+/);
3414
3508
  const type = trimChars(asciiLower(link.params.type || ""), HTTP_WHITESPACE);
3415
3509
  const isMarkdownHeader = trimChars(type.split(";")[0], HTTP_WHITESPACE) === "text/markdown";
3416
- if (!found.describedby && href && rel.includes("describedby"))
3510
+ if (!found.describedby && href && !pointsNowhere(href) && rel.includes("describedby"))
3417
3511
  found.describedby = href;
3418
3512
  if (!found.markdown && href && rel.includes("alternate") && isMarkdownHeader)
3419
3513
  found.markdown = href;
@@ -3465,7 +3559,9 @@ export async function validateHost(input, opts = {}) {
3465
3559
  // its first 120 characters into stderr and the --json error (Tek-496). Such an entry is
3466
3560
  // named by the host the parser reads from it, or not at all, as the hosted form does.
3467
3561
  const raw = String(input ?? "");
3468
- const shown = /[@?#]/.test(raw) ? typedHostEcho(raw) : stripControls(cut(raw, 120));
3562
+ // The text of the error leaves without control, bidirectional or invisible characters, as the text quoted from a file
3563
+ // does (K20 of the Antigravity review, 2026-12-01).
3564
+ const shown = /[@?#]/.test(raw) ? typedHostEcho(raw) : stripInvisible(stripControls(stripBidi(cut(raw, 120))));
3469
3565
  throw new Error(shown ? "not a public domain name: " + shown : "not a public domain name");
3470
3566
  }
3471
3567
  // opts comes from the caller, and path and accept exist for this function's own
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turva-llms-txt-validator",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Validate a site's llms.txt structure: eight checks as pass/warn/fail plus two llms.txt v2 discovery checks that read pass or info and never move the summary, JSON output. Same checks as the hosted validator at turva.dev/llms-txt-validator.",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",