mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-20 22:03:48 +00:00
docs(infra): clarify extractFeedLinks href-resolution comment
This commit is contained in:
@@ -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) ?? "");
|
||||||
|
|||||||
Reference in New Issue
Block a user