The domain (actually authority component) of an HTML5 URL.
If the input is not hierarchical, then the return value is undefined.
191201
static String domainOf(String url) {
    int start = -1;
    if (url.startsWith("//")) {
      start = 2;
    } else {
      start = url.indexOf("://");
      if (start >= 0) { start += 3; }
    }
    if (start < 0) { return null; }
    for (int i = 0; i < start - 3; ++i) {
      switch (url.charAt(i)) {
      case '/': case '?': case '#': return null;
      default: break;
      }
    }
    int end = url.length();
    for (int i = start; i < end; ++i) {
      switch (url.charAt(i)) {
      case '/': case '?': case '#': end = i; break;
      default: break;
      }
    }
    if (start < end) {
      return url.substring(start, end);
    } else {
      return null;
    }
  }
811592
function getDomainFromURL(url) {
  if (url) {
    let domain;
    // find & remove protocol (http, ftp, etc.) and get domain
    if (url.indexOf('://') > -1) {
      domain = url.split('/')[2];
    } else {
      domain = url.split('/');
    }

    // find & remove port number
    domain = domain.split(':');

    return domain;
  }
  return null;
}
460160
function(u){
      var urlObj = url.parse(u)
      return urlObj.protocol + "//" + urlObj.hostname + urlObj.pathname 
    }
476667
def get_domain_name(url):
    
    if not url.startswith("http"):
        url = "http://" + url
    if not is_valid_url(url):
        raise ValueError("Invalid URL '%s'" % url)
    parse = urlparse(url)
    return parse.netloc
99858
function determineBaseURL(url) {

	var baseURL;

	// Check if url is set
	if (url) {

		// Remove whitespace
		baseURL = url.trim();

		baseURL = correctHttpAndHttps(baseURL);
		baseURL = correctQuestionMarkAndAnd(baseURL);
		baseURL = removeParameters(baseURL);

	} else {
		// Throw error (no url)
		throw new Error('The url parameter is not set.');
	}

	return baseURL;
}
992252
function checkDomain(result) {
  // TODO: check against some config value for the domain or similar
  return function(domain, options, callback) {
    result.domain = domain;
    return callback(null, true);
  };
}
110305
def url_norm (url, encoding=None):
    """"""
    try:
        return urlutil.url_norm(url, encoding=encoding)
    except UnicodeError:
        msg = _("URL has unparsable domain name: %(name)s") % \
            {"name": sys.exc_info()[1]}
        raise LinkCheckerError(msg)
100824
def __isValidUrl(self, addr):
        
        regex = re.compile(
            r'^(?:http)s?://'  #: http:// or https://
            r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'  #: domain...
            r'localhost|'  #: localhost...
            r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'  #: ...or ip
            r'(?::\d+)?'  #: optional port
            r'(?:/?|[/?]\S+)$', re.IGNORECASE)
        if addr and isinstance(addr, string_types):
            if regex.match(addr):
                return True
        return False
949803
function () {
        if (!this.host) {
            return E;
        }

        return _.isArray(this.host) ? this.host.join(DOMAIN_SEPARATOR) : this.host.toString();
    }
509112
def get_domain_home_from_url(url):
    
    p = parse.urlparse(url)
    if p.netloc:
        return '{}://{}'.format(p.scheme, p.netloc), p.netloc
    else:
        return '', ''
694154
function() {
    var url = this.url;
    if (this.useHash) {
      url = addHash(url, this);
    }
    // if (this.useDomain) {
      if (!this.domain) {
        this.domain = getDomain(this.subpath);
      } else if (Array.isArray(this.domain)) {
        this.domain = getDomain(this.subpath, this.domain);
      }
      url = this.domain + url;
    // }

    return url + this.query;
  }
619802
function(url) {

         var parts = url.match(/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/);
         var result = {
             url : parts[0],
             scheme : parts[1],
             host : parts[3],
             port : parts[4],
             path : parts[5],
             query : parts[6],
             fragment : parts[7],
         };
         result.root =
            result.scheme + '://' +
            result.host +
            (result.port ? ':' + result.port : '');

         return result;

    }
398666
function ( obj ) {
		return obj.nodeName === "FORM" ? false : string.isDomain( obj.value || element.text( obj ) );
	}
919121
def url(value):
    
    if not url_regex.search(value):
        message = u"{0} is not a valid URL".format(value)
        if url_regex.search('http://' + value):
            message += u". Did you mean: http://{0}".format(value)
        raise ValueError(message)
    return value
1104539
def url2domain(url):
    
    parsed_uri = urlparse.urlparse(url)
    domain = '{uri.netloc}'.format(uri=parsed_uri)
    domain = re.sub("^.+@", "", domain)
    domain = re.sub(":.+$", "", domain)
    return domain
701194
function urlEncodeIfNecessary(s) {
		var regex = /[\\\"<>\.;]/;
		var hasBadChars = regex.exec(s) != null;
		return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
	}
21012
def domain_parse(url):
    
    url = url.lower()
    if not url.startswith('http://') and not url.startswith('https://'):
        url = '{schema}{host}'.format(schema='http://', host=url)
    url = urlparse(url)
    if not url.hostname:
        raise ValueError('Invalid domain provided')

    # Strip www prefix any additional URL data
    url = urlparse('{scheme}://{host}'.format(scheme=url.scheme, host=url.hostname.lstrip('www.')))
    return url