From 07032e13fd2e7d0bc32d108f85d7eec29f21e169 Mon Sep 17 00:00:00 2001 From: Walter Scheper Date: Wed, 1 Sep 2021 22:57:34 -0400 Subject: [PATCH] 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 --- tld.go | 14 ++------------ update_tld.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 12 deletions(-) create mode 100755 update_tld.sh diff --git a/tld.go b/tld.go index f3c25b8..aa9bc46 100644 --- a/tld.go +++ b/tld.go @@ -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 @@ -224,7 +224,6 @@ CAREERS CARS CASA CASE -CASEIH CASH CASINO CAT @@ -236,7 +235,6 @@ CBRE CBS CC CD -CEB CENTER CEO CERN @@ -474,7 +472,6 @@ FRONTDOOR FRONTIER FTR FUJITSU -FUJIXEROX FUN FUND FURNITURE @@ -640,11 +637,9 @@ ISTANBUL IT ITAU ITV -IVECO JAGUAR JAVA JCB -JCP JE JEEP JETZT @@ -760,7 +755,6 @@ LTD LTDA LU LUNDBECK -LUPIN LUXE LUXURY LV @@ -849,7 +843,6 @@ NA NAB NAGOYA NAME -NATIONWIDE NATURA NAVY NBA @@ -862,7 +855,6 @@ NETFLIX NETWORK NEUSTAR NEW -NEWHOLLAND NEWS NEXT NEXTDIRECT @@ -910,7 +902,6 @@ ONE ONG ONL ONLINE -ONYOURSIDE OOO OPEN ORACLE @@ -1110,7 +1101,6 @@ SHOPPING SHOUJI SHOW SHOWTIME -SHRIRAM SI SILK SINA @@ -1144,7 +1134,6 @@ SPA SPACE SPORT SPOT -SPREADBETTING SR SRL SS @@ -1358,6 +1347,7 @@ XN--42C2D9A XN--45BR5CYL XN--45BRJ9C XN--45Q11C +XN--4DBRK0CE XN--4GBRIM XN--54B7FTA0CC XN--55QW42G diff --git a/update_tld.sh b/update_tld.sh new file mode 100755 index 0000000..b6b6186 --- /dev/null +++ b/update_tld.sh @@ -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 +// +// 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