followability
Decide whether a link on a served page is actually followed, in dependency-free Rust.
Three signals answer that question and they have to be read together:
- the link's own
relattribute —nofollow,ugcandsponsoredall withhold the follow; - the page's
<meta name="robots">content, whosenofollowapplies to every link on the page; - the
X-Robots-Tagresponse header, which says the same things from outside the HTML and may be scoped to a named user agent.
Reading only the first is the common mistake: a link with no rel at all is still not followed
if the response carried X-Robots-Tag: nofollow.
use ;
// rel="noopener noreferrer" is a followed link
assert!;
// a bare anchor is still not followed if the header says so
let page = new.with_x_robots_tag;
let v = audit_link;
assert!;
assert_eq!;
// noindex does not withhold the follow — it is a separate question
let page = new.with_meta_robots;
let v = audit_link;
assert!;
assert!;
// scoped headers only bind their agent
let page = new.with_x_robots_tag;
assert!;
assert!;
Handled: the HTML rel token grammar (ASCII case-insensitive, whitespace-separated, commas
tolerated), none as shorthand for noindex, nofollow, contradictions resolved
most-restrictive-wins, valued directives such as max-snippet:-1 whose colon is not a
user-agent separator, and multiple X-Robots-Tag headers merged per agent.
Install
[]
= "0.1"
#![forbid(unsafe_code)], no dependencies, MSRV 1.63. Fetching the page is your job; this
crate reads what came back.
Licence
MIT OR Apache-2.0.
Written for the link pipeline at https://handsofflinks.com/.