"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getLinkDomain = getLinkDomain;
// Ignored via go/ees005
// eslint-disable-next-line require-unicode-regexp
var PROTOCOL_REGEX = /^(.*):\/\//;
// Ignored via go/ees005
// eslint-disable-next-line require-unicode-regexp
var WWW_PREFIX_REGEX = /^(www\.)/;
// Ignored via go/ees005
// eslint-disable-next-line require-unicode-regexp
var URL_SUFFIX_REGEX = /[:\/?#](.*)$/;

// eslint-disable-next-line jsdoc/require-jsdoc
function getLinkDomain(url) {
  // Remove protocol and www., if either exists
  var withoutProtocol = url.toLowerCase().replace(PROTOCOL_REGEX, '');
  var withoutWWW = withoutProtocol.replace(WWW_PREFIX_REGEX, '');
  // Remove port, fragment, path, query string
  return withoutWWW.replace(URL_SUFFIX_REGEX, '');
}