diff --git a/test/test.ts b/test/test.ts index 914ac60..5b5cb7d 100644 --- a/test/test.ts +++ b/test/test.ts @@ -13,4 +13,10 @@ tap.test('should get whois info for domain', async () => { console.log(whoisInfo); }); +tap.test('should check for a valid tld', async () => { + const comIsValid = await testSmartWhois.isValidTld('.com'); + console.log(comIsValid); + expect(comIsValid).toBeTrue(); +}) + tap.start(); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 07d5440..93a82fb 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@pushrocks/smartwhois', - version: '1.0.3', + version: '1.0.4', description: 'a package for dealing with whois requests' } diff --git a/ts/index.ts b/ts/index.ts index 5693c36..90e0989 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -21,5 +21,13 @@ export class SmartWhois { }; } + public async isValidTld(tldArg: string): Promise { + const allTlds = await plugins.whoiser.allTlds(); + const sanatizedTld = tldArg.startsWith('.') + ? tldArg.replace('.', '').toUpperCase() + : tldArg.toUpperCase(); + return allTlds.includes(sanatizedTld); + } + public async getWhoisForIp(ipArg: string) {} -} \ No newline at end of file +}