url
Returns the Punycode ASCII serialization of the domain. If domain is an invalid domain, the empty string is returned.
import { domainToASCII } from 'node:url';
console.log(domainToASCII('español.com'));// Prints xn--espaol-zwa.comconsole.log(domainToASCII('中文.com'));// Prints xn--fiq228c.comconsole.log(domainToASCII('xn--iñvalid.com'));// Prints an empty string
Returns the Unicode serialization of the domain. If domain is an invalid domain, the empty string is returned.
It performs the inverse operation to domainToASCII()
.
import { domainToUnicode } from 'node:url';
console.log(domainToUnicode('xn--espaol-zwa.com'));// Prints español.comconsole.log(domainToUnicode('xn--fiq228c.com'));// Prints 中文.comconsole.log(domainToUnicode('xn--iñvalid.com'));// Prints an empty string