• Tutorials Logic, IN
  • +91 8092939553
  • info@tutorialslogic.com

NodeJS URL Modules

URL Modules

Url module is one of the core modules in NodeJS, which provides utilities for URL resolution and parsing. To include the URL module, use the require() method:-

										    
											var url = require('url');
											
										

The NodeJS URL module is one of the very important modules, which provides various properties to deal with URL, which includes the following:-

URL Module PropertiesDescription
hrefIt provides the complete URL string.
protocolIt is used to gets and sets the protocol portion of the URL.
hostIt returns the hostname and port number.
hostnameIt returns the lower-cased hostname portion of the host component.
portIt returns the port number specified in the URL.
pathnameIt is used to gets and sets the path portion of the URL.
searchIt is used to gets and sets the serialized query portion of the URL.
queryIt returns either the params portion of the query string, or a querystring-parsed object.
hashIt is used to gets and sets the fragment portion of the URL.