This repository was archived by the owner on Aug 10, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -300,7 +300,18 @@ - (NSString *)urlString:(NSString *)s {
300300 }
301301
302302 if (!self.link ) {
303- // TODO: get feed URL and use that to resolve URL.*/
303+ NSURL *feedURL = [NSURL URLWithString: self .urlString];
304+ if (!feedURL) {
305+ return s;
306+ }
307+ NSURL *baseURL = [NSURL URLWithString: [NSString stringWithFormat: @" %@ ://%@ " , feedURL.scheme, feedURL.host]];
308+ if (!baseURL) {
309+ return s;
310+ }
311+ NSURL *resolvedURL = [NSURL URLWithString: s relativeToURL: baseURL];
312+ if (resolvedURL.absoluteString ) {
313+ return resolvedURL.absoluteString ;
314+ }
304315 return s;
305316 }
306317
Original file line number Diff line number Diff line change @@ -185,4 +185,13 @@ class RSSParserTests: XCTestCase {
185185// XCTAssertNotNil(article.contentHTML)
186186// }
187187// }
188+
189+ func testFeedWithHomeEmpty( ) {
190+ let d = parserData ( " fuli51 " , " html " , " https://www.fuli51.net/feed " )
191+ let parsedFeed = try ? FeedParser . parse ( d)
192+
193+ for article in parsedFeed? . items ?? [ ] {
194+ XCTAssertTrue ( article. url? . starts ( with: " https://www.fuli51.net " ) ?? false )
195+ }
196+ }
188197}
You can’t perform that action at this time.
0 commit comments