node url.parse()

Assume that this is a url http://localhost:8080/a/b/c?a=1&
protocol: ‘HTTP:’,// protocol
host: ‘localhost:8080’,
port: ‘8080’,// port
hostname: ‘localhost’, domain
hash: ‘#abcd’,
search: ‘?a=1& B = 2 ‘,
query: ‘a = 1 & amp; B =2 ‘,
pathname: ‘/a/b/c’,
path: ‘/a/b/c?a=1& B = 2 ‘,
href: ‘http://localhost:8080/a/b/c?a=1& B = 2 # ABC ‘
Url.parse () can break a complete URL into many parts, such as host, port, Pathname, path, and Query

var http = require("http");
var url = require("url");

var server = http.createServer(function(req,res){
    var pathname = url.parse(req.url).pathname;
    var query = url.parse(req.url).query;
    console.log("patname:"+ pathname);
    console.log(query);
    res.end();
});
server.listen(80,"127.0.0.1");

Read More: