A robust Punycode converter that fully complies to RFC 3492 and RFC 5891, and works on nearly all JavaScript platforms.
93
Quality
Pending
Does it follow best practices?
Impact
93%
1.17xAverage score across 10 eval scenarios
Build a module that converts punycoded domain names and email addresses into their Unicode form while leaving non-punycoded parts untouched.
shop.xn--caf-dma.com becomes shop.café.com, and legacy dot separators (such as 。 or 。) are treated the same as . during conversion @testbücher.de or example.com) are returned unchanged, even when the conversion is applied repeatedly @testalice@xn--xmpl-loa.test becomes alice@exämple.test while preserving the local part exactly as provided @testxn--invalid_domain) results in a thrown RangeError @test@generates
/**
* Converts a domain name string to its Unicode form, normalizing legacy separators and decoding punycoded labels; throws RangeError for malformed punycode.
*/
export function toUnicodeDomain(input);
/**
* Converts only the domain portion of an email address to Unicode while leaving the local part unchanged; throws RangeError for malformed punycode labels.
*/
export function toUnicodeEmail(input);Provides Punycode-based domain and email conversions.
Install with Tessl CLI
npx tessl i tessl/npm-punycodedocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10