Repository: cypress-io/cypress
File: packages/network/lib/agent.ts (TypeScript)

Code before:
    if (typeof options === 'string') {
      // @ts-ignore
      options = {
        host: options,
        port: port!,
        localAddress,
      }
    }

    // If the path property is a fully qualified URL, which is what as Axios appears to set,
    // parse the URL and set the href, path, and port based on this path
    if (typeof options.path === 'string' && /^http(s)?:\/\//.test(options.path)) {
      const pathUrl = new URL(options.path)
      const portToSet = pathUrl.port ?? options.port

      options.href = options.path
      options.path = pathUrl.pathname

      if (portToSet) {
        options.port = Number(portToSet)
      }
    }

    const isHttps = isRequestHttps(options)

    // Ensure that an HTTPS requests are using 443
    if (isHttps && options.port === 80) {
      options.port = 443
    }

    if (!options.href) {
      // options.path can contain query parameters, which url.format will not-so-kindly urlencode for us...
      // so just append it to the resultant URL string
      options.href = url.format({
        protocol: isHttps ? 'https:' : 'http:',
        slashes: true,
        hostname: options.host,
        port: options.port,
      }) + options.path
    }

    const uri = options.uri = options.uri ?? url.parse(options.href)

    debug('addRequest called %o', { isHttps, ..._.pick(options, 'href') })

    return getFirstWorkingFamily(options, this.familyCache, (family: net.family) => {
      options.family = family

      debug('got family %o', _.pick(options, 'family', 'href'))

      if (isHttps) {

Review comment (suggestion):
```suggestion
    // Ensure that HTTPS requests are using 443
```

Code after:
    if (typeof options === 'string') {
      // @ts-ignore
      options = {
        host: options,
        port: port!,
        localAddress,
      }
    }

    // If the path property is a fully qualified URL, which is what as Axios appears to set,
    // parse the URL and set the href, path, and port based on this path
    if (typeof options.path === 'string' && /^http(s)?:\/\//.test(options.path)) {
      const pathUrl = new URL(options.path)
      const portToSet = pathUrl.port ?? options.port

      options.href = options.path
      options.path = pathUrl.pathname

      if (portToSet) {
        options.port = Number(portToSet)
      }
    }

    const isHttps = isRequestHttps(options)

    // Ensure that HTTPS requests are using 443
    if (isHttps && options.port === 80) {
      options.port = 443
    }

    if (!options.href) {
      // options.path can contain query parameters, which url.format will not-so-kindly urlencode for us...
      // so just append it to the resultant URL string
      options.href = url.format({
        protocol: isHttps ? 'https:' : 'http:',
        slashes: true,
        hostname: options.host,
        port: options.port,
      }) + options.path
    }

    const uri = options.uri = options.uri ?? url.parse(options.href)

    debug('addRequest called %o', { isHttps, ..._.pick(options, 'href') })

    return getFirstWorkingFamily(options, this.familyCache, (family: net.family) => {
      options.family = family

      debug('got family %o', _.pick(options, 'family', 'href'))

      if (isHttps) {