Skip to content

Commit

Permalink
(bug-fix): properly parse co.jp domains
Browse files Browse the repository at this point in the history
  • Loading branch information
mdn1023 committed Nov 16, 2023
1 parent 9a2de08 commit 87d4294
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 2 deletions.
2 changes: 1 addition & 1 deletion parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestParse(t *testing.T) {
}

if !assert.IsContains([]string{"", "aq", "au", "br", "ch", "de", "eu", "gov", "ee",
"hm", "int", "name", "nl", "nz", "tk", "kz", "hu"}, extension) {
"hm", "int", "name", "nl", "nz", "tk", "kz", "hu"}, extension) && !strings.Contains(domain, "co.jp") {
assert.NotZero(t, whoisInfo.Domain.ExpirationDate)
assert.NotNil(t, whoisInfo.Domain.ExpirationDateInTime)
}
Expand Down
2 changes: 1 addition & 1 deletion prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ func prepareRU(text string) string {
return result
}

var prepareJPreplacerRx = regexp.MustCompile(`\n\[(.+?)\][\ ]*(.+?)?`)
var prepareJPreplacerRx = regexp.MustCompile(`\n(?:\w+\.\s)?\[(.+?)\][\ ]*(.+?)?`)

// prepareJP do prepare the .jp domain
func prepareJP(text string) string {
Expand Down
1 change: 1 addition & 0 deletions testdata/noterror/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ If there is any problem, please feel free to open a new issue.
| .jobs | [google.jobs](jobs_google.jobs) | [google.jobs](jobs_google.jobs.json) ||
| .jobs | [ybs.jobs](jobs_ybs.jobs) | [ybs.jobs](jobs_ybs.jobs.json) ||
| .jp | [git.jp](jp_git.jp) | [git.jp](jp_git.jp.json) ||
| .jp | [google.co.jp](jp_google.co.jp) | [google.co.jp](jp_google.co.jp.json) ||
| .jp | [google.jp](jp_google.jp) | [google.jp](jp_google.jp.json) ||
| .kr | [git.kr](kr_git.kr) | [git.kr](kr_git.kr.json) ||
| .kr | [google.kr](kr_google.kr) | [google.kr](kr_google.kr.json) ||
Expand Down
27 changes: 27 additions & 0 deletions testdata/noterror/jp_google.co.jp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[ 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'. ]
[ ]
[ Notice -------------------------------------------------------------------- ]
[ JPRS will add the [Lock Status] element to the response format of JP domain ]
[ name on November 12, 2023. ]
[ For further information, please see the following webpage. ]
[ https://jprs.jp/whatsnew/notice/2023/231112.html (only in Japanese) ]
[ --------------------------------------------------------------------------- ]
Domain Information:
a. [Domain Name] GOOGLE.CO.JP
g. [Organization] Google Japan G.K.
l. [Organization Type] GK
m. [Administrative Contact] YN47525JP
n. [Technical Contact] SH36113JP
p. [Name Server] ns1.google.com
p. [Name Server] ns2.google.com
p. [Name Server] ns3.google.com
p. [Name Server] ns4.google.com
s. [Signing Key]
[State] Connected (2024/03/31)
[Lock Status] AgentChangeLocked
[Registered Date] 2001/03/22
[Connected Date] 2001/03/22
[Last Update] 2023/04/01 01:05:57 (JST)
25 changes: 25 additions & 0 deletions testdata/noterror/jp_google.co.jp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"domain": {
"domain": "google.co.jp",
"punycode": "google.co.jp",
"name": "google.co",
"extension": "jp",
"status": [
"connected"
],
"name_servers": [
"ns1.google.com",
"ns2.google.com",
"ns3.google.com",
"ns4.google.com"
],
"created_date": "2001/03/22",
"updated_date": "2023/04/01 01:05:57 (JST)"
},
"administrative": {
"name": "YN47525JP"
},
"technical": {
"name": "SH36113JP"
}
}
27 changes: 27 additions & 0 deletions testdata/noterror/jp_google.co.jp.pre
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[ 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'. :
:
Notice -------------------------------------------------------------------- :
JPRS will add the [Lock Status: element to the response format of JP domain ]
name on November 12, 2023. :
For further information, please see the following webpage. :
https://jprs.jp/whatsnew/notice/2023/231112.html (only in Japanese) :
--------------------------------------------------------------------------- :
Domain Information:
Domain Name: GOOGLE.CO.JP
Organization: Google Japan G.K.
Organization Type: GK
Administrative Contact: YN47525JP
Technical Contact: SH36113JP
Name Server: ns1.google.com
Name Server: ns2.google.com
Name Server: ns3.google.com
Name Server: ns4.google.com
Signing Key:
State: Connected (2024/03/31)
Lock Status: AgentChangeLocked
Registered Date: 2001/03/22
Connected Date: 2001/03/22
Last Update: 2023/04/01 01:05:57 (JST)

0 comments on commit 87d4294

Please sign in to comment.