Kit: do not crash on [abcd::] with missing port
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
d8568b0e31
commit
b67acaccff
|
@ -52,6 +52,7 @@ extension Endpoint {
|
||||||
let startOfHost = string.index(after: string.startIndex)
|
let startOfHost = string.index(after: string.startIndex)
|
||||||
guard let endOfHost = string.dropFirst().firstIndex(of: "]") else { return nil }
|
guard let endOfHost = string.dropFirst().firstIndex(of: "]") else { return nil }
|
||||||
let afterEndOfHost = string.index(after: endOfHost)
|
let afterEndOfHost = string.index(after: endOfHost)
|
||||||
|
if afterEndOfHost == string.endIndex { return nil }
|
||||||
guard string[afterEndOfHost] == ":" else { return nil }
|
guard string[afterEndOfHost] == ":" else { return nil }
|
||||||
startOfPort = string.index(after: afterEndOfHost)
|
startOfPort = string.index(after: afterEndOfHost)
|
||||||
hostString = String(string[startOfHost ..< endOfHost])
|
hostString = String(string[startOfHost ..< endOfHost])
|
||||||
|
|
Loading…
Reference in New Issue