aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Models
diff options
context:
space:
mode:
Diffstat (limited to 'Hotline/Models')
-rw-r--r--Hotline/Models/Server.swift7
1 files changed, 7 insertions, 0 deletions
diff --git a/Hotline/Models/Server.swift b/Hotline/Models/Server.swift
index da4f01f..62c6867 100644
--- a/Hotline/Models/Server.swift
+++ b/Hotline/Models/Server.swift
@@ -14,6 +14,13 @@ struct Server: Codable {
self.port = port
self.users = users
}
+
+ static func parseServerAddressAndPort(_ address: String) -> (String, Int) {
+ let url = URL(string: "hotline://\(address)")
+ let port = url?.port ?? HotlinePorts.DefaultServerPort
+ let host = url?.host(percentEncoded: false) ?? address
+ return (host, port)
+ }
}
extension Server: Identifiable {