Node | URL.domainToASCII
The url.host is an inbuilt application programming interface of class URL with in url module.
It returns the Punycode ASCII serialization of the domain. If domain is an invalid domain, the empty string is returned.
Syntax :
const url.domainToASCII
Domain value : string
Return value : string
Example :
const url = require('url'); console.log(url.domainToASCII('español.com')); console.log(url.domainToASCII('??.com')); console.log(url.domainToASCII('xn--iñvalid.com')); |
chevron_right
filter_none
OUTPUT:
xn--espaol-zwa.com xn--fiq228c.com // Prints an empty string in the 3'rd case
Note : It performs the inverse operation to url.domainToUnicode().
Recommended Posts:
- Why Node.js ?
- Node js | OS
- Node | URL.fileURLToPath API
- Node | URL.pathToFileURL API
- Node | URL.hash API
- Node | URL.protocol API
- Node | URL.domainToUnicode
- Node | URL.host API
- Node | URLSearchParams.get()
- Node.js Events
- Node | URLSearchParams.set()
- Node | URL.format API
- Node | URL.password API
- Node | URL.pathname API
- Node | URL.port API
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



