function extractHostPortViaProxy(opts) {
  const pathname = opts.pathname || opts.path

  if (pathname && (pathname.startsWith('https://') || pathname.startsWith('http://'))) {
    const url = new URL(pathname)
    return {
      host: url.host,
      hostname: url.hostname,
      port: url.port || url.protocol === 'https:' ? '443' : '80'
    }
  }

  return null
}
Extracts the host, hostname, and port from HTTP request options when using a proxy

@param {object} opts HTTP request options
@returns {object|null} { host, hostname, port } if proxy request is detected, or null otherwise.