1
0
Fork 0
mirror of https://git.anardil.net/austin/verify-links.git synced 2026-11-18 11:00:09 +00:00
Verify links in static web resources
  • Haskell 97%
  • HTML 2.6%
  • Makefile 0.4%
Find a file
Gandalf- af472ec021 verify-links: hold each page to its canonical with --site
With --site, a page carries one <link rel="canonical"> naming it in full
at the shortest URL nginx serves it from: /x/ for x/index.html, /x.html,
or /x with --html-ext unless a file or directory x answers first. A
relative or off-site canonical, a query or fragment, a second canonical
and a missing one each fail; a missing one is allowed by the URL it
should carry. A fragment (no <html>) and a meta-refresh page need none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 09:13:46 -08:00
Links verify-links: hold each page to its canonical with --site 2026-11-09 09:13:46 -08:00
src verify-links: check a built site's links offline, and anardil.net links live (#332) 2026-10-22 14:21:45 -07:00
test verify-links: hold each page to its canonical with --site 2026-11-09 09:13:46 -08:00
.gitignore verify-links: check a built site's links offline, and anardil.net links live (#332) 2026-10-22 14:21:45 -07:00
.hlint.yaml verify-links: take trySync, tryIO, tshow and the recorder from anardil (#429) 2026-11-01 21:12:15 -08:00
CLAUDE.md verify-links: say where a redirect goes, and --allow a known-good link (#354) 2026-10-22 18:33:21 -07:00
hie.yaml verify-links: check a built site's links offline, and anardil.net links live (#332) 2026-10-22 14:21:45 -07:00
LICENSE verify-links: check a built site's links offline, and anardil.net links live (#332) 2026-10-22 14:21:45 -07:00
Makefile verify-links: lines are held to 100 columns by make lint (#456) 2026-11-06 12:58:48 -08:00
README.md verify-links: hold each page to its canonical with --site 2026-11-09 09:13:46 -08:00
stack.yaml verify-links: take trySync, tryIO, tshow and the recorder from anardil (#429) 2026-11-01 21:12:15 -08:00
stack.yaml.lock verify-links: take trySync, tryIO, tshow and the recorder from anardil (#429) 2026-11-01 21:12:15 -08:00
verify-links.cabal verify-links: hold each page to its canonical with --site 2026-11-09 09:13:46 -08:00

verify-links

Checks a built static site's links: every href, src, srcset and poster in every page, against the files in the tree, offline. With --site it also holds each page to its canonical. With --remote it also probes the site's links to anardil.net and its subdomains, live.

verify-links [--site HOST] [--html-ext] [--remote] [--allow LINK]... DIR
  • A link to /x/ passes when x/index.html exists, and a link to /x when x or x/index.html does. --html-ext also accepts x.html, for sites whose nginx block has the @htmlext fallback.
  • --site HOST checks https://HOST/... links in the tree as well.
  • With --site HOST, every page carries one <link rel="canonical"> that names it in full, as https://HOST/ and the shortest path nginx serves it from: x/index.html as /x/, x.html as /x.html, or with --html-ext as /x, unless a file or directory x answers /x first. The root takes its slash or not, and escapes are read as the server reads them. A relative canonical, a query or fragment, or another host fails as wrong canonical LINK -> WANT; each canonical after a page's first as another canonical LINK; and a page with none as no canonical WANT, which --allow WANT lets through. A fragment, with no <html> tag, and a page whose meta refresh sends the reader to a URL need none, but one they carry is judged. A canonical's link is checked as any other.
  • A tag written inside a style, title or textarea is read as markup, and its link checked: a false failure rather than a missed link. Script text is not read as markup. A <!-- there with no --> hides the links after it.
  • A link is read as a browser reads it: control characters and spaces at its ends are dropped, and tabs and newlines inside it removed. Any other space, NBSP included, is part of the link.
  • Links are looked up by their exact case, as the server does, even on a case-insensitive filesystem. A symlinked directory is not followed, so a link into one is reported missing.
  • Any http:// link fails, and so does one that climbs above the root or won't parse. Other people's sites, mailto: and the like are not checked.
  • --remote asks for each https URL on anardil.net or a subdomain (other than --site) as written, through the system resolver and no proxy, and a 2xx passes. A redirect is not followed: it fails, and says where it goes, as http 301 LINK -> TARGET with the Location resolved against LINK.
  • A page behind a login passes, and the summary counts it behind a login: a 401, or a redirect to the same scheme, host and port that carries the link's path (with or without its query) or the whole link as a query value, under any parameter name, or that comes from the site's root. So /dashboards -> /login?redirectTo=%2Fdashboards and / -> /login pass, and /blog -> /blog/ or anardil.net -> www.anardil.net fail. A name that doesn't resolve, which is what a LAN-only host looks like off the LAN, is reported as unresolved. Each request has a 10 second timeout to connect and answer, though a DNS lookup that stalls can take longer before it is reported.
  • --allow LINK accepts a link known to be fine: one that fails, written as the failure prints it, on any page, for any reason. LINK is read as a link on a page is. The link is checked as usual, and probed with --remote, so an allow that allowed nothing gets a note on stderr: no page links to it, it isn't checked (another site, mailto: and the like) or it passes. The note doesn't change the exit code. An allow for a remote link that wasn't probed gets no note: it might yet fail.

Failures go to stdout, one per page and link (page: kind link), and a summary to stderr, which counts the failures allowed. Exit 0 when clean, 1 for any failure not allowed, 2 when the tree can't be checked: no such directory, no pages, an unreadable tree, no http client for --remote, or bad arguments.

make release   # installs ~/.local/bin/verify-links
make ready     # format, lint, test