Node.js url.domainToUnicode() Method Last Updated : 30 Jun, 2020 Comments Improve Suggest changes Like Article Like Report The url.domainToUnicode() method is an inbuilt application programming interface of class URL with in url module which is used to get the domain for the particular ASCII value. Syntax: const url.domainToUnicode(domain) Parameter:s This method takes ASCII value as a parameter which is going to be converted in Unicode. Return value: This method returns the unicode value of the particular domain. Below programs illustrates the use of url.domainToUnicode() method. Example 1: javascript // Node.js program to demonstrate the // URL.domainToUnicode() method // Importing the 'url' module const http = require('url'); // Getting Unicode value // by using domainToUnicode() api const ascivalue = http.domainToUnicode( "xn--espaol-zwa.com"); // Display result for each value entry console.log("Unicode value : " + ascivalue); // Getting Unicode value // by using domainToUnicode() api const ascivalue1 = http.domainToUnicode("google.com"); // display result for each value entry console.log("\nUnicode value : " + ascivalue1); Output: ASCII value : xn--espaol-zwa.com ASCII value : google.com Example 2: javascript // Node.js program to demonstrate the // URL.domainToUnicode() API as Setter // Importing the module 'url' const http = require('url'); // Getting Unicode value // by using domainToUnicode() api const ascivalue = http.domainToUnicode( "geeksforgeeks.com"); // Display result for each value entry console.log("Unicode value : " + ascivalue); // Getting Unicode value // by using domainToUnicode() api const ascivalue1 = http.domainToUnicode("xn--iñvalid.com"); // Display result for each value entry console.log("\nUnicode value : " + ascivalue1); Output: Unicode value : geeksforgeeks.com Unicode value : NOTE: The above program will not run on online JavaScript and script editor. Reference: https://nodejs.org/dist/latest-v14.x/docs/api/url.html#url_url_domaintounicode_domain Comment More infoAdvertise with us Next Article Node.js URL.hash API rohitprasad3 Follow Improve Article Tags : Web Technologies Node.js Node-URL Similar Reads MethodsNode.js URL() MethodThe 'url' module provides utilities for URL resolution and parsing. The getters and setters implement the properties of URL objects on the class prototype, and the URL class is available on the global object. The new URL() (Added in v7.0.0, v6.13.0) method is an inbuilt application programming inter 3 min read Node url.toString() MethodThe url.toString() method is an inbuilt application programming interface(API) of the URL module within the Node.JS. The url.toString() method is used to return the serialized URL. The returned value is equivalent to that of url.href and url.toJSON(). Syntax: url.toString() Parameters: This method a 1 min read Node.js URL.toJSON() MethodThe url.toJSON() method in the node.js URL module is used to return the serialized URL of the URL object. The return value of this method is equivalent to the URL.href and url.toString() methods. If an URL object is serialized using JSON.stringify() method then it is called automatically. Syntax: u 2 min read Node.js url.domainToUnicode() MethodThe url.domainToUnicode() method is an inbuilt application programming interface of class URL with in url module which is used to get the domain for the particular ASCII value. Syntax: const url.domainToUnicode(domain) Parameter:s This method takes ASCII value as a parameter which is going to be con 2 min read APINode.js URL.hash APIThe 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: 1 min read Node.js URL.host APIThe 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: 1 min read Node.js URL.origin APIurl.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:  javascript //Importing the url m 1 min read Node.js URL.username APIURL.username is an inbuilt application programming interface(API) of the URL class within Node.JS. URL.username API is used to get and set the username of the URL. Syntax: url.username URL: It is an object created by a URL constructor. Example 1: (Getting the username of URL) javascript //Creatin 1 min read Node.js URL.search APIURL.search is an inbuilt application programming interface(API) of the URL class within the Node.JS. URL.search API is used to get and set the query part of URL.  Syntax: url.search url : It is an object created by URL constructor. Example 1: (Getting query string of the URL)  javascript //Creatin 1 min read Node.js URL.port APIThe url.port is an inbuilt application programming interface of class URL within url module which is used to get and set the port portion of the URL.the port value may be a number or a string containing a number in the range 0 to 65535 (inclusive). Setting the value to the default port of the URL ob 2 min read Node.js URL.pathname APIThe url.pathname is an inbuilt application programming interface of class URL with in url module which is used to get and set the pathname portion of the URL. Syntax: const url.pathname Return value: It gets and sets the pathname portion of the URL. Below programs illustrate the use of url.pathname 1 min read Node.js URL.password APIThe 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.passwo 1 min read Node.js URL.href APIThe 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 creati 2 min read Node.js URL.hostname APIThe 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 val 1 min read Node.js URL.pathToFileURL APIThis URL.pathToFileURL function converts the path to a file and ensures that the URL control characters (/, \, : ) are correctly appended/adjusted when converting the given path into a File URL. Syntax: url.pathToFileURL(path) Parameters: This function accepts a single parameter path that holds the 2 min read Node.js URL.fileURLToPath APIThis URL.fileURLToPath function decodes the file URL to a path string and ensures that the URL control characters (/, %) are correctly appended/adjusted when converting the given file URL into a path. Syntax: url.fileURLToPath( url ) Parameters: This function accepts single parameter url which holds 1 min read Node.js url.parse(urlString, parseQueryString, slashesDenoteHost) APIThe url.parse() method takes a URL string, parses it, and it will return a URL object with each part of the address as properties. Syntax: url.parse( urlString, parseQueryString, slashesDenoteHost) Parameters: This method accepts three parameters as mentioned above and described below: urlString: 2 min read Special Schemes of Node.js URL.protocol APIThe url.protocol is an inbuilt application programming interface of class URL within URL module which is used to get and set the protocol scheme of the URL. Syntax: const url.protocol Return value: It get and set protocol scheme of the URL Example 1: This example changes the special protocols to hy 3 min read Node.js URL.protocol APIThe url.protocol is an inbuilt application programming interface of class URL within url module which is used to get and set the protocol portion of the URL. When a URL is parsed using one of the special protocols, the url.protocol property may be changed to another special protocol but cannot be ch 2 min read Node.js URL.domainToASCIIThe 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 1 min read Node.js URL.domainToUnicodeThe 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 : 1 min read Node.js URL.resolve(from,to) APIThe url.resolve(from, to) is inbuilt method of class URL that resolves a target URL relative to a base URL. Syntax: url.resolve(from, to); Where, from: (type:String) The base URL being resolved against. to : (type:String) The "href" URL being resolved. Return value: It returns the resolved URL by gi 1 min read Node.js URL.format(urlObject) APIThe 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 retu 4 min read Node.js URL.format APIWith the help of url.format()method, we are able to format the hostname according to our need. We have different types of other parameters which we can use to generate the hostname or to change the hostname as required. Syntax : url.format(URL[, options]) Parameter : auth is a boolean value if true 2 min read URLSearchParamsNode.js URLSearchParams.append()In URLSearchParams interface, the append() method adds a key/value pair specified by user. Syntax: URLSearchParams.append(name, value) Parameters: name - Input the parameter name to append value - Input the parameter value to append Example1: javascript let url = new URL('https://example.com?par=1 1 min read Node.js URLSearchParams.delete()In URLSearchParams interface, the delete() method deletes the parameter specified by user and all its associated values. Syntax: URLSearchParams.delete(name) Parameters: name - The name of the parameter to be deleted. Example 1: javascript let url = new URL('https://example.com?par=1&bar=2&p 1 min read Node.js URLSearchParams.entries()In the URLSearchParams interface, the entries() method returns an iterator that allows iterating through all the key/value pairs present in the object. The key/value is USVString objects. Syntax: searchParams.entries(); Return: Iterator, iterating over all key-value pairs. Example 1: javascript / 1 min read Node.js URLSearchParams.forEach()In URLSearchParams interface, the foreach() method returns an iterator which allows to iterate through all values contained in this object with the help of a callback function. Syntax: searchParams.forEach(callback); Return: It does not return anything, used for invoking the function and iterating t 1 min read Node.js URLSearchParams.get()In URLSearchParams interface, the get() method returns the first value of the input search parameter. Syntax: URLSearchParams.get(name) Returns:The string will be returned if the name-value pair is found, else null will be returned. Parameters: name - Input the name of the parameter. Example1: When 1 min read Node.js urlSearchParams.get() MethodThe urlSearchParams.get() method is an inbuilt application programming interface of class URLSearchParams within url module which is used to get the value for particular name entry present in the URL search params object. Syntax: const urlSearchParams.get( name ) Parameter: This method takes the nam 2 min read Node.js URLSearchParams.getAll()In URLSearchParams interface, the getAll() method returns all the values of the input search parameter in the form of an array. Syntax: URLSearchParams.getAll(name) Returns: An array of string according to the name-value pairs, else an empty array will be returned. Parameters: name - Input the name 1 min read Node.js URLSearchParams.sort()In the URLSearchParams interface, the sort() method helps to sort all keys/pairs in place. The sort criteria are unicode points of the keys. This method uses a stable sorting algorithm. Syntax: searchParams.sort(); Return: Sorted order of existing name-value pairs in place by their names. Example 1 min read Node.js urlSearchParams.toString() MethodThe urlSearchParams.toString() method is an inbuilt application programming interface of class URLSearchParams within url module which is used to get the object of uri search params object as a string. Syntax:  const urlSearchParams.toString() Parameter: This method does not accept any parameter.R 2 min read Node.js urlSearchParams.keys() MethodThe urlSearchParams.keys() method is an inbuilt application programming interface of the URLSearchParams class within url module which is used to get the iterator object containing all the name entries only of URL search params object. Syntax: const urlSearchParams.keys() Parameter: This method does 2 min read Node.js urlSearchParams.values()In the URLSearchParams interface, the values() method returns an iterator which allows us to iterate through all the values present in the object Syntax: searchParams.values(); Return: Returns an ES6 Iterator over the values of each name-value pair. Example 1: In this example, we will see the use of 1 min read Node.js URLSearchParams.set()In URLSearchParams interface, the set() method sets the value given as an input parameter.If there are several values matching the input parameter then it deletes the others and if the value does not exist then it creates it. Syntax: URLSearchParams.set(name, value) Parameters: name - Input the name 1 min read Node.js URLSearchParams.toString()In URLSearchParams interface, the toString() method returns a query string which is suitable for use in a URL. Syntax: URLSearchParams.toString() Return:Returns the search parameters serialized as a string(with Characters percent-encoded). Example 1: javascript let url = new URL('https://example.com 1 min read Node.js URLSearchParams.keys()In URLSearchParams interface, the keys() method returns an Iterator which allows us to iterate through all the keys present in the object. Syntax: searchParams.keys(); Return:Returns an ES6 Iterator over the names of each name-value pair. Example 1: javascript var searchParams = new URLSearchParams( 1 min read Node.js URLSearchParams.has() MethodIn URLSearchParams interface, the has() method returns a Boolean which tells us that if the parameter with input name exists it will return true, else false. Syntax: var Bool = URLSearchParams.has(name) Returns: True - if name present, else it will return False. Parameters: name - Input the name of 1 min read urlObjectNode.js urlObject.auth APIWith the help of urlObject.auth() method, we can find the authentication parameter within the hostname. This method returns the string of parameters. Syntax : urlObject.auth() Return: Returns the string of authentication parameters. Example 1: In this example with the help of urlObject.auth() meth 1 min read Node.js urlObject.hash APIBefore we go on to learn about URL objects API we need to know a brief about URL. If you ever wanted to provide utilities so as to parse or resolute your URL, we can do it through the URL Module. We can divide the URL Module into two parts:- These are- URL String and URL Object. The urlObjectHash is 1 min read Node.js urlObject.host APIThe utilities for URL resolution and parsing is provided by the URL module. A URL string is a structured string that contains various multiple meaningful components. When parsed, a URL object is returned that contains properties for each of these components. url.host() return the host name in the ur 1 min read Node.js urlObject.search APIThe urlObject.search() method in Node is used to get the search query within the hostname which is followed by the '?' character. Syntax : urlObject.search() Return : Returns the search query after '?' character. Example #1 : In these examples, we have shown how the urlObject.search() method is able 1 min read Node.js urlObject.protocol APIWith the help of urlObject.protocol() method, we can find the name of protocol which is used by the given hostname. Syntax : urlObject.protocol() Return : Returns the protocol used (i.e. - http, https, ftp, etc.) Example #1 : In this example, with the help of urlObject.protocol() method we are able 1 min read Node.js urlObject.href APIThe urlObject.href API is used to return the complete URL string along with the protocols(HTTP) and pathname or other search terms. Syntax: urlObject.hrefFor example: 'http://www.geeksforgeeks.com/login/password.html' Here, Protocol = http Path = /login Host = 'www' File Name = password.html Exampl 1 min read Node.js urlObject.query APIThe urlObject.query is the query string returned without the ASCII question mark (?) or an object returned by the query string module named as parse() method. The url.parse() method is used to check whether the query is a string or an object. Basically, the argument (parseQueryString) that is passed 2 min read Node.js urlObject.slashes APIThe urlObject.slashes property is used when one wants to check whether there is a need for ASCII valued forward-slash character (/) after the colon (:) in the protocol (HTTP or HTTPS) of a URL or not. It returns the Boolean value. Syntax: urlObject.slashes Return Value: The urlObject.slashes proper 1 min read Node.js urlObject.port APIThe urlObject.port() method in Node is used to get the numeric port portion of the host component within the hostname. The URLâs port number is returned otherwise None if the port number is not present in the URL. Syntax: urlObject.port() Return: Returns the URL port number or None Example 1: In the 1 min read Node.js urlObject.pathname APIWith the help of urlObject.pathname() method, we can find the name of the path which is used by the given hostname. This contains all the things starting from the host (with the port) and before the beginning of the query or hash components, which are delimited by one of the ASCII question mark (?) 1 min read Like