Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
THE WORLD'S LARGEST WEB DEVELOPER SITE

Node.js URL Module

❮ Built-in Modules


Example

Parse the url string into a URL object and extract the href property:

var http = require('http');
var url = require('url');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  var q = url.parse(req.url, true);
  res.write(q.href);
  res.end();
}).listen(8080);
Run example »

Definition and Usage

The URL module provides a way of parsing the URL string.


Syntax

The syntax for including the url module in your application:

var url = require('url');

URL Methods

Method Description
url.format() Returns a formatted URL string
url.parse() Returns a URL object
url.resolve() Resolves a URL

❮ Built-in Modules