From ba1c2cd2b942d982c3bad860bfed4fcd6ce3c990 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Tue, 4 Apr 2023 14:20:27 -0700 Subject: [PATCH] Fix broken website links that have missing https:// prefixes Changelog-Fixed: Fix broken website links that have missing https:// prefixes --- damus/Nostr/Nostr.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/damus/Nostr/Nostr.swift b/damus/Nostr/Nostr.swift index 0b341ebb..efaca025 100644 --- 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? {