Fix broken website links that have missing https:// prefixes

Changelog-Fixed: Fix broken website links that have missing https:// prefixes
This commit is contained in:
William Casarin
2023-04-04 14:20:27 -07:00
parent bedf7e0648
commit ba1c2cd2b9

View File

@@ -98,7 +98,13 @@ struct Profile: Codable {
}
var website_url: URL? {
return self.website.flatMap { URL(string: $0) }
return self.website.flatMap { url in
let trim = url.trimmingCharacters(in: .whitespacesAndNewlines)
if !(trim.hasPrefix("http://") || trim.hasPrefix("https://")) {
return URL(string: "https://" + trim)
}
return URL(string: trim)
}
}
var lnurl: String? {