code: 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;
  }
docs: http://stackoverflow.com/questions/8498592/extract-root-domain-name-from-string