Skip to content

Commit 07032e1

Browse files
committed
Add script to update top-level domains
This adds a simple shell script to update the tld.go constant with the latest contents of https://data.iana.org/TLD/tlds-alpha-by-domain.txt
1 parent 54f00e4 commit 07032e1

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

tld.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package rapid
99
import "strings"
1010

1111
// sourced from https://data.iana.org/TLD/tlds-alpha-by-domain.txt
12-
// Version 2020103100, Last Updated Sat Oct 31 07:07:01 2020 UTC
12+
// Version 2021090100, Last Updated Thu Sep 2 02:57:25 UTC 2021
1313
const tldsByAlpha = `
1414
AAA
1515
AARP
@@ -224,7 +224,6 @@ CAREERS
224224
CARS
225225
CASA
226226
CASE
227-
CASEIH
228227
CASH
229228
CASINO
230229
CAT
@@ -236,7 +235,6 @@ CBRE
236235
CBS
237236
CC
238237
CD
239-
CEB
240238
CENTER
241239
CEO
242240
CERN
@@ -474,7 +472,6 @@ FRONTDOOR
474472
FRONTIER
475473
FTR
476474
FUJITSU
477-
FUJIXEROX
478475
FUN
479476
FUND
480477
FURNITURE
@@ -640,11 +637,9 @@ ISTANBUL
640637
IT
641638
ITAU
642639
ITV
643-
IVECO
644640
JAGUAR
645641
JAVA
646642
JCB
647-
JCP
648643
JE
649644
JEEP
650645
JETZT
@@ -760,7 +755,6 @@ LTD
760755
LTDA
761756
LU
762757
LUNDBECK
763-
LUPIN
764758
LUXE
765759
LUXURY
766760
LV
@@ -849,7 +843,6 @@ NA
849843
NAB
850844
NAGOYA
851845
NAME
852-
NATIONWIDE
853846
NATURA
854847
NAVY
855848
NBA
@@ -862,7 +855,6 @@ NETFLIX
862855
NETWORK
863856
NEUSTAR
864857
NEW
865-
NEWHOLLAND
866858
NEWS
867859
NEXT
868860
NEXTDIRECT
@@ -910,7 +902,6 @@ ONE
910902
ONG
911903
ONL
912904
ONLINE
913-
ONYOURSIDE
914905
OOO
915906
OPEN
916907
ORACLE
@@ -1110,7 +1101,6 @@ SHOPPING
11101101
SHOUJI
11111102
SHOW
11121103
SHOWTIME
1113-
SHRIRAM
11141104
SI
11151105
SILK
11161106
SINA
@@ -1144,7 +1134,6 @@ SPA
11441134
SPACE
11451135
SPORT
11461136
SPOT
1147-
SPREADBETTING
11481137
SR
11491138
SRL
11501139
SS
@@ -1358,6 +1347,7 @@ XN--42C2D9A
13581347
XN--45BR5CYL
13591348
XN--45BRJ9C
13601349
XN--45Q11C
1350+
XN--4DBRK0CE
13611351
XN--4GBRIM
13621352
XN--54B7FTA0CC
13631353
XN--55QW42G

update_tld.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
TLD_URL=https://data.iana.org/TLD/tlds-alpha-by-domain.txt
6+
TLD="$(curl -fsSL https://data.iana.org/TLD/tlds-alpha-by-domain.txt | grep -v '^#')"
7+
8+
cat > tld.go << EOF
9+
// Copyright 2020 Walter Scheper <walter.scheper@gmail.com>
10+
//
11+
// This Source Code Form is subject to the terms of the Mozilla Public
12+
// License, v. 2.0. If a copy of the MPL was not distributed with this
13+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
14+
15+
package rapid
16+
17+
import "strings"
18+
19+
// sourced from https://data.iana.org/TLD/tlds-alpha-by-domain.txt
20+
// Version $(date +%Y%m%d00), Last Updated $(date --utc)
21+
const tldsByAlpha = \`
22+
${TLD}
23+
\`
24+
25+
var tlds = strings.Split(strings.TrimSpace(tldsByAlpha), "\n")
26+
EOF

0 commit comments

Comments
 (0)