Skip to main content
Module

x/tld_validator/mod.ts

Deno 🦕 module to check if a TLD is valid.
File
const url = "https://data.iana.org/TLD/tlds-alpha-by-domain.txt";
const response = await fetch(url);const domainList = await response.text();
export function validateTLD(tld: string) { const inputRegEx = new RegExp(`\\b${tld.toUpperCase()}\\b`); if (domainList.search(inputRegEx) != -1) { return true; } else { return false; }}