aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Sources/WireGuardKit/Endpoint.swift1
1 files changed, 1 insertions, 0 deletions
diff --git a/Sources/WireGuardKit/Endpoint.swift b/Sources/WireGuardKit/Endpoint.swift
index d86290f..8454d87 100644
--- a/Sources/WireGuardKit/Endpoint.swift
+++ b/Sources/WireGuardKit/Endpoint.swift
@@ -52,6 +52,7 @@ extension Endpoint {
let startOfHost = string.index(after: string.startIndex)
guard let endOfHost = string.dropFirst().firstIndex(of: "]") else { return nil }
let afterEndOfHost = string.index(after: endOfHost)
+ if afterEndOfHost == string.endIndex { return nil }
guard string[afterEndOfHost] == ":" else { return nil }
startOfPort = string.index(after: afterEndOfHost)
hostString = String(string[startOfHost ..< endOfHost])