docs(infra): clarify extractFeedLinks href-resolution comment

This commit is contained in:
Julien Herr
2026-05-25 17:12:08 +02:00
parent 3c48181c05
commit 86d18eb390
+6 -5
View File
@@ -69,11 +69,11 @@ export function extractLinks(
return links; return links;
} }
// Collect a newsletter's self-advertised feed declarations: // Collect a newsletter's self-advertised feed declarations from
// <link rel="alternate" type="application/(atom|rss)+xml|feed+json" href="…">. // <link rel="alternate" type="…"> tags. Returns raw href+type tuples; the
// Returns raw href+type tuples; the domain decides which MIME types are feeds. // domain decides which MIME types count as a feed. Relative hrefs are
// Relative hrefs are absolutized against the sender base (best-effort); only // absolutized against the sender base (best-effort); only http(s) URLs survive.
// http(s) URLs survive. Plain-text bodies have no <link> → []. // Plain-text bodies have no <link> → [].
export function extractFeedLinks( export function extractFeedLinks(
content: string, content: string,
base = "", base = "",
@@ -88,6 +88,7 @@ export function extractFeedLinks(
const type = (el.getAttribute("type") ?? "").trim(); const type = (el.getAttribute("type") ?? "").trim();
const rawHref = (el.getAttribute("href") ?? "").trim(); const rawHref = (el.getAttribute("href") ?? "").trim();
if (!type || !rawHref) return; if (!type || !rawHref) return;
// toAbsolute() skips already-absolute hrefs (returns null), so keep those as-is.
const href = /^https?:\/\//i.test(rawHref) const href = /^https?:\/\//i.test(rawHref)
? rawHref ? rawHref
: (toAbsolute(rawHref, base) ?? ""); : (toAbsolute(rawHref, base) ?? "");