Node.js has a built-in URL module that you can use to parse URLs. Below is an example of how you can use it:
First, you need to require the URL module.
```
var url = require(‘url’);
```
Then you can use the `url.parse()` method to parse any URL.
```
var url = require(‘url’);
var address = ‘http://localhost:8080/default.htm?year=2017&month=february’;
var q = url.parse(address, true);
console.log(q.host); //returns ‘localhost:8080‘
console.log(q.pathname); //returns ‘/default.htm‘
console.log(q.search); //returns ‘?year=2017&month=february’
var qdata = q.query; //returns an object: { year: 2017, month: ‘february’ }
console.log(qdata.month); //returns ‘february‘
```
The “url.parse()” method returns an object containing the following information:
- `href`: The full URL
- `protocol`: The protocol of the URL (http: or https:)
- `hostname`: The domain name of the website
- `port`: The port number
- `pathname`: The path section of the URL
- `search`: The query string including the leading question mark
- `query`: An object containing each part of the query string as a property
- `hash`: The fragment identifier including the leading hash sign
In the example, “url.parse()” method also parse the query string and set the `parseQueryString` argument to “true”. This will make “q.query” an object which you can use to access each query string parameter individually as shown above.
For more sophisticated URL parsing, consider using third-party libraries such as `url-parse` or `query-string`.