The URL module in Node.js is used to work with and analyze URLs.
const { URL } = require("url");
const myURL = new URL(
"https://example.com/products?id=101"
);
console.log("Host:", myURL.host);
console.log("Path:", myURL.pathname);
console.log("Query:", myURL.search);