url.domainToUnicode(domain)


新增于: v7.4.0, v6.13.0

返回 domain 的 Unicode 序列化。如果 domain 是无效域,则返回空字符串。

\Returns the Unicode serialization of the domain. If domain is an invalid domain, the empty string is returned.

它执行与 url.domainToASCII() 相反的操作。

\It performs the inverse operation to url.domainToASCII().

只有在启用 ICU 的情况下编译 node 可执行文件时,此功能才可用。否则,域名将原封不动地通过。

\This feature is only available if the node executable was compiled with ICU enabled. If not, the domain names are passed through unchanged.

import url from 'node:url';
console.log(url.domainToUnicode('xn--espaol-zwa.com'));
// Prints español.com
console.log(url.domainToUnicode('xn--fiq228c.com'));
// Prints 中文.com
console.log(url.domainToUnicode('xn--iñvalid.com'));
// Prints an empty stringconst url = require('node:url');
console.log(url.domainToUnicode('xn--espaol-zwa.com'));
// Prints español.com
console.log(url.domainToUnicode('xn--fiq228c.com'));
// Prints 中文.com
console.log(url.domainToUnicode('xn--iñvalid.com'));
// Prints an empty string

AltStyle によって変換されたページ (->オリジナル) /