一、引入
const url = require('url')
二、url.parse(str)(记住统一资源定位符各部分的英文名称)
let myurl = 'https://www.cnblogs.com/jaci/p/11470688.html?us=yp&ps=123#/abc'
let myurlObj = url.parse(myurl)
{
protocol: 'https:',
slashes: true,
auth: null,
host: 'www.cnblogs.com:8080',
port: '8080',
hostname: 'www.cnblogs.com',
hash: '#/abc',
search: '?us=yp&ps=123',
query: 'us=yp&ps=123',
pathname: '/jaci/p/11470688.html',
path: '/jaci/p/11470688.html?us=yp&ps=123',
href:'https://www.cnblogs.com:8080/jaci/p/11470688.html?us=yp&ps=123#/abc'
}
三、url.format(obj)对象转成字符串