Open In App

Node.js URL.domainToASCII

Last Updated : 14 Oct, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

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'));


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().


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads