mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
link and URL vars for Article. Storage as rawLink
link and externalLink fall back to providing the raw stored value if URLs cannot be created even with repair.
This commit is contained in:
@@ -42,4 +42,16 @@ extension URL {
|
||||
return value
|
||||
|
||||
}
|
||||
|
||||
static func reparingIfRequired(_ link: String?) -> URL? {
|
||||
// If required, we replace any space characters to handle malformed links that are otherwise percent
|
||||
// encoded but contain spaces. For performance reasons, only try this if initial URL init fails.
|
||||
guard let link = link, !link.isEmpty else { return nil }
|
||||
if let url = URL(string: link) {
|
||||
return url
|
||||
} else {
|
||||
return URL(string: link.replacingOccurrences(of: " ", with: "%20"))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user