This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private struct InterfaceNames { | |
static let wifi = ["en0"] | |
static let wired = ["en2", "en3", "en4"] | |
static let cellular = ["pdp_ip0", "pdp_ip1", "pdp_ip2", "pdp_ip3"] | |
static let supported = wifi + wired + cellular | |
} | |
private func ipAddresses() -> [String] { | |
var addresses = [String]() | |
var ifaddr: UnsafeMutablePointer<ifaddrs>? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension URL { | |
private func splitQuery(_ query: String) -> [String: [String]] { | |
return query.components(separatedBy: "&").map { $0.components(separatedBy: "=") }.reduce(into: [String: [String]]()) { result, element in | |
guard !element.isEmpty, | |
let key = element[0].removingPercentEncoding, | |
let value = element.count >= 2 ? element[1].removingPercentEncoding : "" else { return } | |
var values = result[key, default: [String]()] | |
values.append(value) | |
result[key] = values |