n8n
Version:
n8n Workflow Automation Tool
38 lines • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HostnameMatcher = void 0;
class HostnameMatcher {
constructor(patterns) {
this.parsed = patterns
.map((p) => this.normalizeHostname(p))
.filter(Boolean)
.map((value) => {
if (value.startsWith('*.')) {
const suffix = value.slice(1);
return { isWildcard: true, suffix };
}
return { isWildcard: false, value };
});
}
matches(hostname) {
const normalizedHostname = this.normalizeHostname(hostname);
for (const pattern of this.parsed) {
if (pattern.isWildcard) {
if (normalizedHostname.endsWith(pattern.suffix) &&
normalizedHostname.length > pattern.suffix.length) {
return true;
}
continue;
}
if (normalizedHostname === pattern.value) {
return true;
}
}
return false;
}
normalizeHostname(hostname) {
return hostname.trim().toLowerCase();
}
}
exports.HostnameMatcher = HostnameMatcher;
//# sourceMappingURL=hostname-matcher.js.map