From f59928f4d506ad3cef60d303f031c6937aa4ae8e Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Mon, 8 Sep 2025 12:03:41 +0100 Subject: [PATCH] Fix proxies by reverting the change that introduced schemes. (#4481) This partially reverts commit 863f28d476a325b7ec0cc25ee69345f5fe0dd60c. --- ElementX/Sources/Other/Extensions/URL.swift | 55 ++++++--------------- 1 file changed, 14 insertions(+), 41 deletions(-) diff --git a/ElementX/Sources/Other/Extensions/URL.swift b/ElementX/Sources/Other/Extensions/URL.swift index a562f97a0..575b26f29 100644 --- a/ElementX/Sources/Other/Extensions/URL.swift +++ b/ElementX/Sources/Other/Extensions/URL.swift @@ -114,49 +114,22 @@ extension URL { } MXLog.info("Found \(String(describing: proxies?.count)) proxies, using the first one.") - - if proxyType == kCFProxyTypeAutoConfigurationURL as String { - MXLog.info("Found proxy auto configuration") + MXLog.info("Proxy type is \(proxyType)") - if let pacURL = firstProxy[kCFProxyAutoConfigurationURLKey] as? String { - MXLog.info("Retrieved global PAC URL: \(pacURL)") - return pacURL - } else { - MXLog.info("Failed retrieving PAC URL") - } - } else { - MXLog.info("Proxy type found as \(proxyType)") - - guard let host = firstProxy[kCFProxyHostNameKey] as? String else { - MXLog.error("Found proxy with invalid host name") - return nil - } - - let port = firstProxy[kCFProxyPortNumberKey] as? Int - - let scheme: String? = if proxyType == kCFProxyTypeHTTP as String { - "http" - } else if proxyType == kCFProxyTypeHTTPS as String { - "https" - } else if proxyType == kCFProxyTypeSOCKS as String { - "socks" - } else { - nil - } - - var components = URLComponents() - components.scheme = scheme - components.host = host - components.port = port - - MXLog.info("Found proxy components: \(String(describing: scheme)), \(host), \(String(describing: port))") - - MXLog.info("Retrieved global proxy: \(String(describing: components.url))") - - return components.url?.absoluteString + guard let host = firstProxy[kCFProxyHostNameKey] as? String else { + MXLog.error("Found proxy with invalid host name") + return nil + } + + let port = firstProxy[kCFProxyPortNumberKey] as? Int + + MXLog.info("Found proxy host: \(host), port: \(String(describing: port))") + + if let port { + return "\(host):\(port)" + } else { + return host } - - return nil } // MARK: Mocks