(url)
| 2427 | } |
| 2428 | |
| 2429 | function parseQueryString(url) { |
| 2430 | const queryString = url.split('?')[1] //获取查询字符串部分 |
| 2431 | const regex = /([^=&]+)=([^&]*)/g //匹配键值对的正则表达式 |
| 2432 | const params = {} |
| 2433 | let match |
| 2434 | |
| 2435 | while ((match = regex.exec(queryString))) { |
| 2436 | const key = decodeURIComponent(match[1]) //解码键 |
| 2437 | const value = decodeURIComponent(match[2]) //解码值 |
| 2438 | params[key] = value //将键值对添加到对象中 |
| 2439 | } |
| 2440 | |
| 2441 | return params |
| 2442 | } |
| 2443 | // 请求 |
| 2444 | async function http(url, opts = {}) { |
| 2445 | const http_start = Date.now() |