1: url.parse('http://imooc.com/course/list')
Url {
slashes: true,
auth: null,
host: 'imooc.com',
port: null,
hostname: 'imooc.com',
hash: null,
search: null,
query: null,
pathname: '/course/list',
path: '/course/list',
href: 'http://imooc.com/course/list' }
>
2:> url.format({
... protocol: 'http:',
... slashes: true,
... auth: null,
... host: 'imooc.com',
... port: null,
... hostname: 'imooc.com',
... hash: null,
... search: null,
... query: null,
... pathname: '/course/list',
... path: '/course/list',
... href: 'http://imooc.com/course/list' })
'http://imooc.com/course/list'
//这样就能得到合法的网址
3: url.resolve('http://imooc.com/','/course/list')
'http://imooc.com/course/list'
>