Add additional Reddit URL validation
This commit is contained in:
parent
ffdeda4a74
commit
faaf280d12
|
@ -29,7 +29,7 @@ public protocol FeedProvider {
|
|||
/// Provide the iconURL of the given URL
|
||||
func iconURL(_ urlComponents: URLComponents, completion: @escaping (Result<String, Error>) -> Void)
|
||||
|
||||
/// Construct the associated metadata for the new feed
|
||||
/// Construct the associated metadata for the new feed. If the URL won't be recognized by this Feed Provider, it will error here.
|
||||
func metaData(_ urlComponents: URLComponents, completion: @escaping (Result<FeedProviderFeedMetaData, Error>) -> Void)
|
||||
|
||||
/// Refresh all the article entries (ParsedItems)
|
||||
|
|
|
@ -124,11 +124,16 @@ public final class RedditFeedProvider: FeedProvider {
|
|||
return
|
||||
}
|
||||
|
||||
guard splitPath.count > 1 else {
|
||||
guard splitPath.count > 1, splitPath.count < 4, splitPath[0] == "r" else {
|
||||
completion(.failure(RedditFeedProviderError.unknown))
|
||||
return
|
||||
}
|
||||
|
||||
if splitPath.count == 3 && RedditSort(rawValue: String(splitPath[2])) == nil {
|
||||
completion(.failure(RedditFeedProviderError.unknown))
|
||||
return
|
||||
}
|
||||
|
||||
let homePageURL = "https://www.reddit.com/\(splitPath[0])/\(splitPath[1])"
|
||||
|
||||
subreddit(urlComponents) { result in
|
||||
|
|
Loading…
Reference in New Issue