Node.js Parse URL

Write a program in node.js to parse the given url.
http://www.etutorialspoint.com/index.php/nodejs/node-js-filesystem

Solution

Whenever a request is made to an HTTP server the request object will contain url property, identifying the targeted resource. This is accessible via request.url. Node's URL module is used to decompose a typical URL string into its constituent parts. Consider the following figure:

console.log(url.parse("http://www.etutorialspoint.com/index.php/nodejs/node-js-filesystem"));

Output of the above code

nodejs parse url

Read more articles


General Knowledge



Learn Popular Language