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:
- Node js | OS
- Why Node.js ?
- Node | URL.domainToUnicode
- Node | URL.username API
- Node | URL.search API
- Node | URL.host API
- Node | URL.fileURLToPath API
- Node | URL.origin API
- Promises in Node.js
- Node | URL.resolve(from,to) API
- Node | URL.href API
- Node | URL.password API
- Node | URL.hostname API
- Routing in Node.js
- Node | URLSearchParams.get()
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.



