GT2/GT2-iOS/node_modules/pac-resolver/dnsDomainIs.js

35 lines
699 B
JavaScript
Raw Normal View History

2018-02-12 17:26:06 +00:00
/**
* Module exports.
*/
module.exports = dnsDomainIs;
/**
* Returns true iff the domain of hostname matches.
*
* Examples:
*
* ``` js
* dnsDomainIs("www.netscape.com", ".netscape.com")
* // is true.
*
* dnsDomainIs("www", ".netscape.com")
* // is false.
*
* dnsDomainIs("www.mcom.com", ".netscape.com")
* // is false.
* ```
*
*
* @param {String} host is the hostname from the URL.
* @param {String} domain is the domain name to test the hostname against.
* @return {Boolean} true iff the domain of the hostname matches.
*/
function dnsDomainIs (host, domain) {
host = String(host);
domain = String(domain);
return host.substr(domain.length * -1) === domain;
}