Horje
Node.js 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'));

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



Reffered: https://www.geeksforgeeks.org


Node.js

Related
Node.js URL.domainToUnicode Node.js URL.domainToUnicode
Node.js urlObject.port API Node.js urlObject.port API
Node.js URL.resolve(from,to) API Node.js URL.resolve(from,to) API
Node.js urlObject.host API Node.js urlObject.host API
Node.js URL.format(urlObject) API Node.js URL.format(urlObject) API

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
12