Handle relative <link> elements in Atom parser — use xml:base when present to resolve. Add test case.

This commit is contained in:
Brent Simmons
2025-01-20 17:59:39 -08:00
parent ccb1b8294e
commit d22f3819cd
3 changed files with 52 additions and 8 deletions

View File

@@ -109,4 +109,22 @@ final class AtomParserTests: XCTestCase {
XCTAssertNotEqual(article.title, "Default Title")
}
}
func testLinkElementsWithRelativeURLs() {
// This feed has <link> elements that look like this
// <link href="/en/publish/2022/07/01/great-moments-in-document-history-reimagining-the-declaration-of-independence-as-pdf"/>
// and it also has, in the feed declaration
// xml:base="https://blog.adobe.com"
// and so the <link> values should be parsed as (for example):
// https://blog.adobe.com/en/publish/2022/07/01/great-moments-in-document-history-reimagining-the-declaration-of-independence-as-pdf
// Issue: https://github.com/Ranchero-Software/NetNewsWire/issues/3662
let d = parserData("adobe", "atom", "https://blog.adobe.com/feed.xml")
let parsedFeed = try! FeedParser.parse(d)!
for article in parsedFeed.items {
XCTAssertTrue(article.url!.hasPrefix("https://blog.adobe.com/en/publish/20"))
}
}
}

File diff suppressed because one or more lines are too long