From 56d6bc91e302ebe019ab8f68231ec2911cba47e4 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 15 Aug 2020 10:42:01 -0500 Subject: [PATCH] Suffix .json on micro.blog feed finds that return a 404. Issue #329 --- Account/Sources/Account/FeedFinder/FeedFinder.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Account/Sources/Account/FeedFinder/FeedFinder.swift b/Account/Sources/Account/FeedFinder/FeedFinder.swift index 6c00ebdf0..d743b629a 100644 --- a/Account/Sources/Account/FeedFinder/FeedFinder.swift +++ b/Account/Sources/Account/FeedFinder/FeedFinder.swift @@ -15,8 +15,17 @@ class FeedFinder { static func find(url: URL, completion: @escaping (Result, Error>) -> Void) { downloadAddingToCache(url) { (data, response, error) in + if response?.forcedStatusCode == 404 { - completion(.failure(AccountError.createErrorNotFound)) + if var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false), urlComponents.host == "micro.blog" { + urlComponents.path = "\(urlComponents.path).json" + if let newURLString = urlComponents.url?.absoluteString { + let microblogFeedSpecifier = FeedSpecifier(title: nil, urlString: newURLString, source: .HTMLLink) + completion(.success(Set([microblogFeedSpecifier]))) + } + } else { + completion(.failure(AccountError.createErrorNotFound)) + } return }