nip05: move nip05 parsing to struct
Going to use this when checking the nip05 identifier
This commit is contained in:
@@ -18,6 +18,14 @@ func isHttpsUrl(_ string: String) -> Bool {
|
|||||||
struct NIP05 {
|
struct NIP05 {
|
||||||
let username: String
|
let username: String
|
||||||
let host: 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 {
|
func isImage(_ urlString: String) -> Bool {
|
||||||
@@ -101,11 +109,7 @@ struct EditMetadataView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var nip05_parts: NIP05? {
|
var nip05_parts: NIP05? {
|
||||||
let parts = nip05.split(separator: "@")
|
return NIP05.parse(nip05)
|
||||||
guard parts.count == 2 else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return NIP05(username: String(parts[0]), host: String(parts[1]))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|||||||
Reference in New Issue
Block a user