Skip to content

fix rss: support rel=self and XML content-type feeds#14

Open
carlotran4 wants to merge 3 commits intoHyaxia:mainfrom
carlotran4:main
Open

fix rss: support rel=self and XML content-type feeds#14
carlotran4 wants to merge 3 commits intoHyaxia:mainfrom
carlotran4:main

Conversation

@carlotran4
Copy link
Copy Markdown

Fixes DiscoverFeedURL to handle two cases:

  1. XML content-type: When a URL already returns RSS/Atom/XML (e.g. techcrunch.com/tag/AI/feed/), use it directly instead of trying to parse HTML.

  2. rel="self" links: Some feeds use rel="self" instead of rel="alternate" in their HTML. Now checks both.

This fixes TechCrunch tag/category feeds which return XML directly and use rel="self" links.

Before: DiscoverFeedURL would fall back to /feed for TechCrunch tag feeds.
After: Correctly returns the tag feed URL.

// Content-type check
if strings.Contains(contentType, "rss") || strings.Contains(contentType, "atom") || strings.Contains(contentType, "xml") {
    return blogURL, nil
}

// rel="self" fallback
selection = doc.Find(fmt.Sprintf("link[rel='self'][type='%s']", feedType)).First()

George added 3 commits April 2, 2026 03:17
- Check content-type header: if URL returns rss/atom/xml, use it directly
  This fixes feeds that return XML instead of HTML (e.g. TechCrunch tag feeds)
- Also check rel="self" in addition to rel="alternate" for feeds that
  use self-referencing links
- Use mime.ParseMediaType for content-type parsing (handles params/case)
- Only accept explicit feed types in content-type (avoid sitemap false positives)
- Use [rel~='value'] token matching for rel attributes
- Use [type~='value'] for case-insensitive type matching

Suggested by Codex review.
JulienTant added a commit to JulienTant/blogwatcher-cli that referenced this pull request Apr 3, 2026
DiscoverFeedURL now handles two additional cases:

1. When a URL already returns a feed content-type (application/rss+xml,
   application/atom+xml, or application/feed+json), return it directly
   instead of trying to parse HTML.

2. When HTML pages use rel="self" instead of rel="alternate" for their
   feed link tags, check both attributes.

This fixes discovery for feeds like TechCrunch tag/category feeds which
return XML directly and may use rel="self" links.

Based on upstream PR #14 by @carlotran4 (Hyaxia/blogwatcher#14),
adapted to our fork's patterns (context threading, testify, etc.).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
JulienTant added a commit to JulienTant/blogwatcher-cli that referenced this pull request Apr 3, 2026
DiscoverFeedURL now handles two additional cases:

1. When a URL already returns a feed content-type (application/rss+xml,
   application/atom+xml, or application/feed+json), return it directly
   instead of trying to parse HTML.

2. When HTML pages use rel="self" instead of rel="alternate" for their
   feed link tags, check both attributes.

This fixes discovery for feeds like TechCrunch tag/category feeds which
return XML directly and may use rel="self" links.

Based on upstream PR #14 by @carlotran4 (Hyaxia/blogwatcher#14),
adapted to our fork's patterns (context threading, testify, etc.).

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant