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