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


Previous Article
Next Article

Similar Reads

Convert relative path URL to absolute path URL using JavaScript
Given a relative URL, the task is to convert the relative URL to an absolute URL. Here, the base URL is also given. 2 approaches are discussed here, the first example has the baseURL provided by the user and the second takes it from the URL of the page. Approach 1: Get the relURL and baseURL from user.Use .split() method to split the base and relat
3 min read
What is URL Locator & what are common schemes used for the URL in HTML ?
Every HTML document on the internet has a unique URL. URL stands for Uniform Resource Locator. The URL is the HTML document's address on the internet. Any file that can be accessed via the internet has a URL, including images, JavaScript files, CSS files, Flash files, and so on. To view an HTML document in a browser, enter the URL of the document i
3 min read
Node.js URL.domainToUnicode
The url.domainToUnicode is an inbuilt application programming interface of class URL with in url module. It returns the Unicode serialization of the domain. If the domain is invalid, the empty string is returned. Syntax : const url.domainToASCII Domain value : string Return value : string Example : const url = require('url'); console.log(url.domain
1 min read
Node.js URL.format(urlObject) API
The URL.format(urlObject) is the inbuilt API provided by URL class, which takes an object or string and return a formatted string derived from that object or string. Syntax: const url.format(urlObject) If the urlObject is not an object or string, then it will throw a TypeError. Return value: It returns string derived from urlObject. The urlObject c
4 min read
Node.js URL.hash API
The url.hash is an inbuilt application programming interface of class URL within url module which is used to get and set the fragment portion of the URL. Syntax: url.hash Return value: It gets and sets the fragment portion of the URL. Below programs illustrate the use of url.hash Method: Example 1: C/C++ Code // node program to demonstrate the // u
1 min read
Node.js URL.host API
The url.host is an inbuilt application programming interface of class URL with in url module which is used to get and set the host portion of the URL. Syntax: const url.host Return value: It gets and sets the host portion of the URL.Below programs illustrates the use of url.host Method:Example 1: C/C++ Code // node program to demonstrate the // url
1 min read
Node.js URL.hostname API
The url.hostname is an inbuilt application programming interface of class URL with in url module which is used to get and set the hostname portion of the URL. The key difference between url.host and url.hostname is that url.hostname does not include the port. Syntax: const url.hostname Return value: It gets and sets the hostname portion of the URL.
1 min read
Node.js URL.href API
The url.href is an inbuilt application programming interface of class URL with in the url module which Gets and sets the serialized URL. Getting the value of the href property is equivalent to calling the url.toString() method.Setting the value of this property to a new value is equivalent to creating a new URL object using new URL(value). Each of
2 min read
Node.js URL.password API
The url.password is an inbuilt application programming interface of class URL with in url module which is used to get and set the password portion of the URL. Syntax: const url.password Return value: It gets and sets the password portion of the URL.Below programs illustrate the use of url.password Method:Example 1: C/C++ Code // node program to dem
2 min read
Node.js URL.origin API
url.origin is an inbuilt application programming interface(API) of the URL class within the url module. url.origin API is used to gets the read-only serialization of the URL’s origin. Syntax: url.origin url : It is an object created by URL constructor. Example 1: C/C++ Code //Importing the url module const url = require('url'); //Creating an URL_1
1 min read
Article Tags :