/ cloudformation-templates / node_modules / aws-cdk / node_modules / pac-resolver / dist / localHostOrDomainIs.js
localHostOrDomainIs.js
1 "use strict"; 2 Object.defineProperty(exports, "__esModule", { value: true }); 3 /** 4 * Is true if the hostname matches exactly the specified hostname, or if there is 5 * no domain name part in the hostname, but the unqualified hostname matches. 6 * 7 * Examples: 8 * 9 * ``` js 10 * localHostOrDomainIs("www.netscape.com", "www.netscape.com") 11 * // is true (exact match). 12 * 13 * localHostOrDomainIs("www", "www.netscape.com") 14 * // is true (hostname match, domain not specified). 15 * 16 * localHostOrDomainIs("www.mcom.com", "www.netscape.com") 17 * // is false (domain name mismatch). 18 * 19 * localHostOrDomainIs("home.netscape.com", "www.netscape.com") 20 * // is false (hostname mismatch). 21 * ``` 22 * 23 * @param {String} host the hostname from the URL. 24 * @param {String} hostdom fully qualified hostname to match against. 25 * @return {Boolean} 26 */ 27 function localHostOrDomainIs(host, hostdom) { 28 const parts = host.split('.'); 29 const domparts = hostdom.split('.'); 30 let matches = true; 31 for (let i = 0; i < parts.length; i++) { 32 if (parts[i] !== domparts[i]) { 33 matches = false; 34 break; 35 } 36 } 37 return matches; 38 } 39 exports.default = localHostOrDomainIs; 40 //# sourceMappingURL=localHostOrDomainIs.js.map