Note
To enable built-in Node.js APIs and polyfills, add the nodejs_compat compatibility flag to your Wrangler configuration file. This also enables nodejs_compat_v2 as long as your compatibility date is 2024-09-23 or later. Learn more about the Node.js compatibility flag and v2.
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.com
console.log(domainToASCII('䏿.com'));
// Prints xn--fiq228c.com
console.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.com
console.log(domainToUnicode('xn--fiq228c.com'));
// Prints 䏿.com
console.log(domainToUnicode('xn--iñvalid.com'));
// Prints an empty string
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4