fix(core): update

This commit is contained in:
2023-04-18 20:40:39 +02:00
parent deba684093
commit bec73de6d5
6 changed files with 51 additions and 21 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartwhois',
version: '1.0.7',
version: '1.0.8',
description: 'a package for dealing with whois requests'
}

View File

@ -38,7 +38,27 @@ export interface IWhoisInfo {
}
export class SmartWhois {
/**
* can be used to prepare an input for the whois command
*/
public async getParsedUrlResultForWhois(urlArg: string) {
const smarturlInstance = plugins.smarturl.Smarturl.createFromUrl(urlArg);
const tldtsData = plugins.tldts.parse(urlArg);
return {
fullUrl: smarturlInstance.toString(),
fullDomain: smarturlInstance.hostname,
domain: tldtsData.domain,
publicSuffix: tldtsData.publicSuffix,
subdomain: tldtsData.subdomain,
}
}
public async getWhoisForDomain(domainArg: string): Promise<IWhoisInfo> {
if (domainArg.includes('//')) {
const parsedUrlResult = await this.getParsedUrlResultForWhois(domainArg);
domainArg = parsedUrlResult.fullDomain;
}
const whoisInfo = await plugins.whoiser.domain(domainArg);
const whoisServers = Object.keys(whoisInfo);
const selectedWhoisInfo: any = whoisInfo[whoisServers[0]];

View File

@ -1,3 +1,10 @@
// pushrocks scope
import * as smarturl from '@pushrocks/smarturl';
export {
smarturl,
}
// third party
import * as whoiser from 'whoiser';
import tldts from 'tldts';