Library to work against complex domain names, subdomains and URIs
82
Build a URL classification service that processes a list of URLs and categorizes them by their domain characteristics.
@generates
The service should process an array of URL strings and return classification results for each URL. For each URL, extract and provide:
The service should handle various URL formats including:
/**
* Classification result for a single URL
*/
export interface UrlClassification {
/** Original URL that was classified */
url: string;
/** Full domain name (e.g., "example.com") */
domain: string | null;
/** Subdomain portion (e.g., "api" from "api.example.com") */
subdomain: string | null;
/** Public suffix/TLD (e.g., "com", "co.uk") */
publicSuffix: string | null;
/** Extracted hostname */
hostname: string | null;
/** Whether the URL is an IP address */
isIp: boolean;
}
/**
* Classifies a list of URLs by extracting domain information
* @param urls - Array of URL strings to classify
* @returns Array of classification results
*/
export function classifyUrls(urls: string[]): UrlClassification[];Provides URL and hostname parsing capabilities.
Install with Tessl CLI
npx tessl i tessl/npm-tldtsdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10