1. decodeURIComponent()函数对URL编码的字符串进行解码, 例如:
const str = 'username=%E4%BA%8B%E5%AE%9E%E4%B8%8A&password=%E9%A1%B6%E9%A1%B6%E9%A1%B6';
const decoded = decodeURIComponent(str);
console.log(decoded);
// username=事实上&password=顶顶顶
2. new URL(), 接收两个参数,
const http = require('http');
const server = http.createServer(function (request, response) {
let res = new URL(request.url, 'http://127.0.0.1:3000')
console.log(res) // 实例化对象挂载多个方法
// console.log(res.searchParams.get())// 通过get获取具体的某个参数
response.end('hello')
})
server.listen(3000, () => {
console.log('服务启动成功...')
})