@param {string} hostname
@returns {{slug: string, name: string, host: string, path: string}}
@example

www.example.com becomes:

{
slug: example
name: Example
host: www.example.com
path: '/'
}
352689
function getDefaultSiteSettings(hostname) {
  const name = _.takeRight(hostname.split('.'), 2)[0]; // penultimate or last

  return {
    slug: name.toLowerCase(),
    name: _.startCase(name),
    host: hostname,
    path: '/',
    prefix: hostname,
    assetDir: 'public'
  };
}
1240599
function generateURL (name) {
  return name
    .toLowerCase()
    .split('')
    .map(char => {
      if (char === ' ') return '-'
      if (specials.includes(char)) return mapped[ specials.indexOf(char) ]
      return char
    })
    .join('')
}
1125475
function getProtohost(url) {
  if (typeof url !== 'string' || url.length === 0 || url[0] === '/') {
    return undefined
  }

  var searchIndex = url.indexOf('?')
  var pathLength = searchIndex !== -1
    ? searchIndex
    : url.length
  var fqdnIndex = url.substr(0, pathLength).indexOf('://')

  return fqdnIndex !== -1
    ? url.substr(0, url.indexOf('/', 3 + fqdnIndex))
    : undefined
}
1110043
function(name) {
    var idx, length, regexp,
      header = this.headers[Utils.headerize(name)],
      result = [];

    if (header) {
      length = header.length;
      for (idx = 0; idx < length; idx++) {
        result.push(header[idx]);
      }
      return result;
    } else {
      length = this.extraHeaders.length;
      regexp = new RegExp('^\\s*'+ name +'\\s*:','i');
      for (idx=0; idx<length; idx++) {
        header = this.extraHeaders[idx];
        if (regexp.test(header)) {
          result.push(header.substring(header.indexOf(':')+1).trim());
        }
      }
      return result;
    }
  }
1267543
function vhostof (req, regexp) {
  var host = req.headers.host
  var hostname = hostnameof(req)

  if (!hostname) {
    return
  }

  var match = regexp.exec(hostname)

  if (!match) {
    return
  }

  var obj = Object.create(null)

  obj.host = host
  obj.hostname = hostname
  obj.length = match.length - 1

  for (var i = 1; i < match.length; i++) {
    obj[i - 1] = match[i]
  }

  return obj
}
414638
def GetClientURNsForHostnames(hostnames, token=None):
  

  if data_store.RelationalDBEnabled():
    index = ClientIndex()
  else:
    index = CreateClientIndex(token=token)

  keywords = set()
  for hostname in hostnames:
    if hostname.startswith("host:"):
      keywords.add(hostname)
    else:
      keywords.add("host:%s" % hostname)
  results = index.ReadClientPostingLists(keywords)

  result = {}
  for keyword, hits in iteritems(results):
    result[keyword[len("host:"):]] = hits
  return result
460160
function(u){
      var urlObj = url.parse(u)
      return urlObj.protocol + "//" + urlObj.hostname + urlObj.pathname 
    }
9627
function(hostname, callback) {
  get_nodes(function(err,nodes) {
    if (err) return callback(err);

    var n = nodes.filter(function(node) {
      return node.name === hostname;
    });

    callback(null,(n.length === 1) ? n[0].ip_address : null);
  });
}
1110682
function generateFileContentForHost(host, teamId) {
  var appID = teamId + '.' + getBundleId();
  var paths = host.paths.slice();

  // if paths are '*' - we should add '/' to it to support root domains.
  // https://github.com/nordnet/cordova-universal-links-plugin/issues/46
  if (paths.length == 1 && paths[0] === '*') {
    paths.push('/');
  }

  return {
    "applinks": {
      "apps": [],
      "details": [{
        "appID": appID,
        "paths": paths
      }]
    }
  };
}
413023
function dnsCompatibleBucketName(bucketName) {
    var b = bucketName;
    var domain = new RegExp(/^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/);
    var ipAddress = new RegExp(/(\d+\.){3}\d+/);
    var dots = new RegExp(/\.\./);
    return (b.match(domain) && !b.match(ipAddress) && !b.match(dots)) ? true : false;
  }
282006
function getFilenames()
{
  var hostname = getHostname()
    , host     = hostname.split('.')[0]
    ;

  return [
    'default',
    '', // allow suffixes as a basename (e.g. `environment`)
    host,
    hostname,
    'local',
    this.defaults.customIncludeFiles,
    this.defaults.customEnvVars,
    'runtime'
  ];
}
1077393
def filter_service_by_regex_host_name(regex):
    
    host_re = re.compile(regex)

    def inner_filter(items):
        """Inner filter for service. Accept if regex match service.host.host_name"""
        service = items["service"]
        host = items["hosts"][service.host]
        if service is None or host is None:
            return False
        return host_re.match(host.host_name) is not None

    return inner_filter
814909
function(path){
        var hosts = this.hosts,
            count = hosts.length;
        return hosts[parseInt(mod_md5(path),16) % count];
    }
253294
def generate_host_keys(hostname: str) -> Iterator[str]:
    
    labels = hostname.split('.')
    for i in range(2, len(labels) + 1):
        domain = '.'.join(labels[-i:])
        yield domain
        yield '.' + domain
337936
function extractProtocolHost(url) {
    const urlNoQuery = url.split('?')[0];
    const [protocol, hostAndPath] = urlNoQuery.split('//');
    const host = hostAndPath.split('/')[0];
    return `${protocol}//${host}`;
}
851171
@Deprecated
  public static boolean verifyHostName(String hostname, String pattern) {
    String canonicalHostname;
    if (hostname.startsWith("[") && hostname.endsWith("]")) {
      // IPv6 address like [2001:db8:0:1:1:1:1:1]
      canonicalHostname = hostname.substring(1, hostname.length() - 1);
    } else {
      // This converts unicode domain name to ASCII
      try {
        canonicalHostname = IDN.toASCII(hostname);
      } catch (IllegalArgumentException e) {
        // e.g. hostname is invalid
        return false;
      }
    }
    return PGjdbcHostnameVerifier.INSTANCE.verifyHostName(canonicalHostname, pattern);
  }
319173
private String getMergedPath(String hostName, Path p, String objectName) {
    if ((p.getParent() != null) && (p.getName() != null)
        && (p.getParent().toString().equals(hostName))) {
      if (objectName.equals(p.getName())) {
        return p.toString();
      }
      if (objectName.startsWith(p.getName())) {
        return p.getParent() + objectName;
      }
      return p.toString();
    }
    return hostName + objectName;
  }