CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-tldts

Library to work against complex domain names, subdomains and URIs

82

1.03x
Overview
Eval results
Files

task.mdevals/scenario-4/

International Domain Validator

Build a domain validator that can handle internationalized domain names (IDN) from various languages and provides detailed information about their structure.

Capabilities

Validates and parses Unicode domains

  • When given the Unicode domain "中国.公司.cn", it extracts the domain, subdomain, and public suffix correctly @test
  • When given the Punycode equivalent "xn--fiqs8s.xn--55qx5d.cn", it extracts the same domain information @test

Extracts information from international email addresses

  • When given an international email address "user@münchen.de", it extracts the domain "münchen.de" @test
  • When given a Japanese email address "田中@例え.jp", it extracts the domain "例え.jp" @test

Handles mixed Unicode and ASCII domains

  • When given "subdomain.例子.com", it correctly identifies "例子.com" as the domain and "subdomain" as the subdomain @test

Implementation

Create a module that exports a function parseInternationalDomain that takes a URL, hostname, or email address string and returns an object containing:

  • domain: The registrable domain
  • subdomain: The subdomain portion (if any)
  • publicSuffix: The public suffix (TLD)
  • isValid: Whether the input contains a valid domain

The function should handle both Unicode and Punycode representations of international domains.

@generates

API

/**
 * Parses international domain names from URLs, hostnames, or email addresses
 *
 * @param {string} input - A URL, hostname, or email address that may contain Unicode characters
 * @returns {object} An object containing domain, subdomain, publicSuffix, and isValid properties
 */
function parseInternationalDomain(input) {
  // Implementation here
}

module.exports = { parseInternationalDomain };

Dependencies { .dependencies }

tldts { .dependency }

Provides URL parsing and domain extraction with Unicode/IDNA support.

Install with Tessl CLI

npx tessl i tessl/npm-tldts

tile.json