本页还没有译文
本页 9 段还没译成日本語,下面显示的是英文原文。url
还没翻译译自英文(developers.cloudflare.com)本页 9 段都还没译
Note
For compatibility dates of 2026-08-04 or later, Workers enables both nodejs_compat and nodejs_compat_v2 by default. These flags are not used for these compatibility dates. Existing projects do not need to remove them when updating their compatibility date. For earlier dates, add nodejs_compat to your Wrangler configuration file to opt in. For instructions to turn off Node.js compatibility, refer to the Node.js compatibility flag.
domainToASCII
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 stringdomainToUnicode
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