mikemaccana / whois-json

Whois with results in actual, structured, camelCased JavaScript!
61 stars 34 forks source link

Add support for `.jp` whois data parsing #29

Closed jamsinclair closed 4 years ago

jamsinclair commented 4 years ago

ℹ️ I realise this library is fairly generic and light, so feel free to close if you'd rather not add specific edge case handling.

The Problem

Whois results show incorrectly for *.jp domains with the current library release:

Querying whois('google.jp')

{ 
  "domainInformation": "[Domain Name]                   GOOGLE.JP",
  "contactInformation": "[Name]                          Google LLC"
}

Why

Because the Japan Registry Services whois results are not using the popular colon-delimited whois data format.

It uses square brackets for fields.

[ JPRS database provides information on network administration. Its use is    ]
[ restricted to network administration purposes. For further information,     ]
[ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e'     ]
[ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'.                 ]

Domain Information:
[Domain Name]                   GOOGLE.JP

[Registrant]                    Google LLC

[Name Server]                   ns1.google.com
[Name Server]                   ns2.google.com
[Name Server]                   ns3.google.com
[Name Server]                   ns4.google.com
...

Solution

I've opted for handling this case specifically based on whether the header used by the JPRS database is present.

We then:

Then the normal parsing of the data resumes.

An alternative could be to try a more generic normalisation of all results.

Thanks for the library! Happy to adjust this PR based on your feedback 😄

jamsinclair commented 4 years ago

Ah looks like @zbone3 has gone for a robust structured approach in #27 that is far better than my changes. I'll close this.