From 44adfe7a1e2b1461ee86d3507f9506e04b22e151 Mon Sep 17 00:00:00 2001 From: Jeroen Leenarts Date: Wed, 3 Oct 2018 10:39:04 +0200 Subject: [PATCH] Do not try to resolve a valid ip address. --- Shared/Validators.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Shared/Validators.swift b/Shared/Validators.swift index 21758fe..a73f329 100644 --- a/Shared/Validators.swift +++ b/Shared/Validators.swift @@ -49,11 +49,16 @@ struct Endpoint { } hostString = hostString.replacingOccurrences(of: "[", with: "").replacingOccurrences(of: "]", with: "") - - let ipString = convertToipAddress(from: hostString) + var addressType = validateIpAddress(ipToValidate: hostString) + let ipString: String + if addressType == .other { + ipString = convertToipAddress(from: hostString) + } else { + ipString = hostString + } ipAddress = String(ipString) - let addressType = validateIpAddress(ipToValidate: ipAddress) + addressType = validateIpAddress(ipToValidate: ipAddress) guard addressType == .IPv4 || addressType == .IPv6 else { throw EndpointValidationError.invalidIP(ipAddress) }