commit 104205394fe5e441644cd64d934940712dd90b77 parent 6593c9456d35389dd4a794854c48d57790ebcf02 Author: William Casarin <jb55@jb55.com> Date: Wed, 4 Jan 2023 00:07:08 -0800 nip05: move nip05 parsing to struct Going to use this when checking the nip05 identifier Diffstat:
M | damus/Views/EditMetadataView.swift | | | 14 | +++++++++----- |
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/damus/Views/EditMetadataView.swift b/damus/Views/EditMetadataView.swift @@ -18,6 +18,14 @@ func isHttpsUrl(_ string: String) -> Bool { struct NIP05 { let username: String let host: String + + static func parse(_ nip05: String) -> NIP05? { + let parts = nip05.split(separator: "@") + guard parts.count == 2 else { + return nil + } + return NIP05(username: String(parts[0]), host: String(parts[1])) + } } func isImage(_ urlString: String) -> Bool { @@ -101,11 +109,7 @@ struct EditMetadataView: View { } var nip05_parts: NIP05? { - let parts = nip05.split(separator: "@") - guard parts.count == 2 else { - return nil - } - return NIP05(username: String(parts[0]), host: String(parts[1])) + return NIP05.parse(nip05) } var body: some View {