n8n-nodes-whois
Version:
Whois request
30 lines • 883 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UrlsUtils = void 0;
const psl_1 = __importDefault(require("psl"));
class UrlsUtils {
isValidUrl(url) {
try {
new URL(url);
return true;
}
catch (error) {
return false;
}
}
getDomain(url) {
var _a;
let hostname = url;
if (this.isValidUrl(url)) {
hostname = new URL(url).hostname;
}
const parsed = psl_1.default.parse(hostname);
console.log('>>> ' + parsed.domain);
return (_a = parsed.domain) !== null && _a !== void 0 ? _a : hostname;
}
}
exports.UrlsUtils = UrlsUtils;
//# sourceMappingURL=UrlsUtils.js.map