Method description:
Say a URL string converted to an object and returned.
grammar:
The code copy is as follows:
url.parse(urlStr, [parseQueryString], [slashesDenoteHost])
Receive parameters:
urlStr url string
When parseQueryString is true, the query module will be used to analyze the query string, which is false by default.
slashesDenoteHost
Default is false, and a string in the form of //foo/bar will be interpreted as { pathname: '//foo/bar' }
If set to true, the string of //foo/bar form will be interpreted as { host: 'foo', pathname: '/bar' }
example:
The code copy is as follows: var url = require('url');
var a = url.parse('http://example.com:8080/one?a=index&t=article&m=default');
console.log(a);
//Output result:
{
protocol : 'http',
auth : null ,
host : 'example.com:8080' ,
port : '8080' ,
hostname : 'example.com' ,
hash : null ,
search : '?a=index&t=article&m=default',
query : 'a=index&t=article&m=default',
pathname : '/one',
path : '/one?a=index&t=article&m=default',
href : 'http://example.com:8080/one?a=index&t=article&m=default'
}