Method description:
Convert a URL string into an object and return it.
Grammar:
url.parse(urlStr, [parseQueryString], [slashesDenoteHost])
Receive parameters:
urlStr URL string
parseQueryString When it is true, the query module will be used to analyze the query string. The default is false
slashesDenoteHost
The default is false, a string in the form //foo/bar will be interpreted as { pathname: ‘//foo/bar’ }
If set to true, a string of the form //foo/bar will be interpreted as { host: ‘foo’, pathname: ‘/bar’ }
Example:
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'
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn