Skip to content

Commit

Permalink
Add script to update top-level domains
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wfscheper committed Sep 2, 2021
1 parent 54f00e4 commit 07032e1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
14 changes: 2 additions & 12 deletions tld.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package rapid
import "strings"

// sourced from https://data.iana.org/TLD/tlds-alpha-by-domain.txt
// Version 2020103100, Last Updated Sat Oct 31 07:07:01 2020 UTC
// Version 2021090100, Last Updated Thu Sep 2 02:57:25 UTC 2021
const tldsByAlpha = `
AAA
AARP
Expand Down Expand Up @@ -224,7 +224,6 @@ CAREERS
CARS
CASA
CASE
CASEIH
CASH
CASINO
CAT
Expand All @@ -236,7 +235,6 @@ CBRE
CBS
CC
CD
CEB
CENTER
CEO
CERN
Expand Down Expand Up @@ -474,7 +472,6 @@ FRONTDOOR
FRONTIER
FTR
FUJITSU
FUJIXEROX
FUN
FUND
FURNITURE
Expand Down Expand Up @@ -640,11 +637,9 @@ ISTANBUL
IT
ITAU
ITV
IVECO
JAGUAR
JAVA
JCB
JCP
JE
JEEP
JETZT
Expand Down Expand Up @@ -760,7 +755,6 @@ LTD
LTDA
LU
LUNDBECK
LUPIN
LUXE
LUXURY
LV
Expand Down Expand Up @@ -849,7 +843,6 @@ NA
NAB
NAGOYA
NAME
NATIONWIDE
NATURA
NAVY
NBA
Expand All @@ -862,7 +855,6 @@ NETFLIX
NETWORK
NEUSTAR
NEW
NEWHOLLAND
NEWS
NEXT
NEXTDIRECT
Expand Down Expand Up @@ -910,7 +902,6 @@ ONE
ONG
ONL
ONLINE
ONYOURSIDE
OOO
OPEN
ORACLE
Expand Down Expand Up @@ -1110,7 +1101,6 @@ SHOPPING
SHOUJI
SHOW
SHOWTIME
SHRIRAM
SI
SILK
SINA
Expand Down Expand Up @@ -1144,7 +1134,6 @@ SPA
SPACE
SPORT
SPOT
SPREADBETTING
SR
SRL
SS
Expand Down Expand Up @@ -1358,6 +1347,7 @@ XN--42C2D9A
XN--45BR5CYL
XN--45BRJ9C
XN--45Q11C
XN--4DBRK0CE
XN--4GBRIM
XN--54B7FTA0CC
XN--55QW42G
Expand Down
26 changes: 26 additions & 0 deletions update_tld.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -eu

TLD_URL=https://data.iana.org/TLD/tlds-alpha-by-domain.txt
TLD="$(curl -fsSL https://data.iana.org/TLD/tlds-alpha-by-domain.txt | grep -v '^#')"

cat > tld.go << EOF
// Copyright 2020 Walter Scheper <walter.scheper@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
package rapid
import "strings"
// sourced from https://data.iana.org/TLD/tlds-alpha-by-domain.txt
// Version $(date +%Y%m%d00), Last Updated $(date --utc)
const tldsByAlpha = \`
${TLD}
\`
var tlds = strings.Split(strings.TrimSpace(tldsByAlpha), "\n")
EOF

0 comments on commit 07032e1

Please sign in to comment.