code: function _getHostAddress (uri, defaultHost, defaultPort) {
        const addr = {};
  
        if (uri === undefined) { // If no uri, use default
          addr.protocol = 'http://';
          addr.port = defaultPort;
          addr.host = defaultHost;
        } else { // Otherwise parse provided uri
          const uriSplit = uri.replace(/http:\/\/|https:\/\//, '').split(':', 2);
  
          addr.protocol = (uri.toLowerCase().indexOf('https') == 0 ? 'https://' : 'http://');
  
          if (uriSplit.length == 0) {
            throw new Error('Invalid webdriveruri specified:' + uri);
          } else if (uriSplit.length < 2) {
            addr.port = defaultPort;
          } else {
            addr.port = uriSplit[1];
          }
          addr.host = uriSplit[0];
        }
        return addr.protocol + addr.host + ':' + addr.port;
      }
docs: Helper: parse address