Normalize homePageURL in its setter. Fix #397.

This commit is contained in:
Brent Simmons 2018-09-02 12:14:04 -07:00
parent 5d2a3e9142
commit fdb159a61b
1 changed files with 17 additions and 4 deletions

View File

@ -16,7 +16,22 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
public let accountID: String
public let url: String
public let feedID: String
public var homePageURL: String?
private var _homePageURL: String?
public var homePageURL: String? {
get {
return _homePageURL
}
set {
if let url = newValue {
_homePageURL = url.rs_normalizedURL()
}
else {
_homePageURL = nil
}
}
}
public var iconURL: String?
public var faviconURL: String?
public var name: String?
@ -86,9 +101,7 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
let feedID = dictionary[Key.feedID] as? String ?? url
self.init(accountID: accountID, url: url, feedID: feedID)
if let homePageURL = dictionary[Key.homePageURL] as? String {
self.homePageURL = homePageURL.rs_normalizedURL()
}
self.homePageURL = dictionary[Key.homePageURL] as? String
self.iconURL = dictionary[Key.iconURL] as? String
self.faviconURL = dictionary[Key.faviconURL] as? String
self.name = dictionary[Key.name] as? String