Skip to content

Commit

Permalink
fixed - query TLD whois from more sources
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiIgna committed Feb 4, 2023
1 parent 4d4be4d commit d5f755e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#### 1.15.0 - 4 February 2023

- Updated - Merge/normalize more WHOIS domain labels
- Fixed - Query more sources for TLD whois server [#86](https://github.com/LayeredStudio/whoiser/pull/86)

#### 1.14.0 - 14 January 2023

- Added - Support for third level domains [#80](https://github.com/LayeredStudio/whoiser/pull/80)
Expand Down
14 changes: 6 additions & 8 deletions src/whoiser.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,22 @@ const whoisTld = async (query, { timeout = 15000, raw = false, domainTld = '' }
data.__raw = result
}

// query for WHOIS server in more sources
// if no whois server found, search in more sources
if (!data.whois) {

//todo
// split `query` in domain parts and request info for all tld combinations
// ex: query="example.com.tld" make 3 requests for "example.com.tld" "com.tld" "tld"
// instead of using `domainTld`, split `query` in domain parts and request info for all tld combinations
// example: query="example.com.tld" make 3 requests for "example.com.tld" / "com.tld" / "tld"

const whois = await whoisTldAlternate(domainTld)
const whois = await whoisTldAlternate(domainTld || query)

if (whois) {
data.whois = whois
data.domain = data.domain || whois
data.refer = data.refer || whois
}
}

if (!data.domain || !data.whois) {
if (!data.domain && !data.whois) {
throw new Error(`TLD "${query}" not found`)
}

Expand Down Expand Up @@ -145,8 +144,7 @@ const whoisDomain = async (rawDomain, { host = null, timeout = 15000, follow = 2
// hardcoded WHOIS queries..
if (host === 'whois.denic.de') {
query = `-T dn ${rawDomain}`
}
if (host === 'whois.jprs.jp') {
} else if (host === 'whois.jprs.jp') {
query = `${query}/e`
}

Expand Down
1 change: 1 addition & 0 deletions test/tlds.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('#whoiser.tld()', function() {

it('should return WHOIS for "analytics" (no whois server)', async function() {
let whois = await whoiser.tld('analytics')
assert.equal(whois.whois, 'whois.nic.analytics', 'WHOIS server doesn\'t match')
assert.equal(whois.domain, 'ANALYTICS', 'TLD doesn\'t match')
assert.equal(whois.created, '2015-11-20', 'Created date doesn\'t match')
});
Expand Down

0 comments on commit d5f755e

Please sign in to comment.