dnsDomainIs.js
 1  "use strict";
 2  Object.defineProperty(exports, "__esModule", { value: true });
 3  /**
 4   * Returns true iff the domain of hostname matches.
 5   *
 6   * Examples:
 7   *
 8   * ``` js
 9   * dnsDomainIs("www.netscape.com", ".netscape.com")
10   *   // is true.
11   *
12   * dnsDomainIs("www", ".netscape.com")
13   *   // is false.
14   *
15   * dnsDomainIs("www.mcom.com", ".netscape.com")
16   *   // is false.
17   * ```
18   *
19   *
20   * @param {String} host is the hostname from the URL.
21   * @param {String} domain is the domain name to test the hostname against.
22   * @return {Boolean} true iff the domain of the hostname matches.
23   */
24  function dnsDomainIs(host, domain) {
25      host = String(host);
26      domain = String(domain);
27      return host.substr(domain.length * -1) === domain;
28  }
29  exports.default = dnsDomainIs;
30  //# sourceMappingURL=dnsDomainIs.js.map