feat: read subscriptions from an Atom feed when a page lists no dated links
This commit is contained in:
parent
b0b86ef5b1
commit
fa51d5793d
9 changed files with 411 additions and 4 deletions
|
|
@ -51,7 +51,7 @@ MewsPage parseMewsPage({required String source, required String url}) {
|
|||
title: headData.title,
|
||||
description: headData.description,
|
||||
author: headData.author,
|
||||
atomFeedHref: headData.atomFeedHref,
|
||||
atomFeedHref: _feedHref(headData.atomFeedHref, url),
|
||||
lang: html.getAttribute('xml:lang') ??
|
||||
html.getAttribute('lang') ??
|
||||
bodyElement.getAttribute('lang') ??
|
||||
|
|
@ -294,6 +294,18 @@ ImageBlock _imageBlock(XmlElement element, String pageUrl) {
|
|||
|
||||
/// Rough registrable-domain match: the last two labels. Fine for the small
|
||||
/// web; a public-suffix list is out of scope for v1.
|
||||
/// The page's Atom feed as an absolute address (spec 6.2), or null when the
|
||||
/// page declares none or points at another site: a client must not load
|
||||
/// another site's resources without the reader acting (specs 7.4 and 8.1).
|
||||
String? _feedHref(String? href, String pageUrl) {
|
||||
if (href == null || href.isEmpty) return null;
|
||||
final page = Uri.tryParse(pageUrl);
|
||||
if (page == null) return null;
|
||||
final resolved = page.resolve(href);
|
||||
if (resolved.scheme != 'http' && resolved.scheme != 'https') return null;
|
||||
return _sameSite(resolved, page) ? resolved.toString() : null;
|
||||
}
|
||||
|
||||
bool _sameSite(Uri image, Uri page) {
|
||||
String? domain(Uri uri) {
|
||||
final host = uri.host;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue