damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit ba1c2cd2b942d982c3bad860bfed4fcd6ce3c990
parent bedf7e0648d3725241f141694076710ae903f031
Author: William Casarin <jb55@jb55.com>
Date:   Tue,  4 Apr 2023 14:20:27 -0700

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

Changelog-Fixed: Fix broken website links that have missing https:// prefixes

Diffstat:
Mdamus/Nostr/Nostr.swift | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/damus/Nostr/Nostr.swift b/damus/Nostr/Nostr.swift @@ -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? {