MCPcopy Create free account
hub / github.com/Script-Hub-Org/Script-Hub / parseQueryString

Function parseQueryString

Rewrite-Parser.beta.js:2841–2854  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

2839}
2840
2841function parseQueryString(url) {
2842 const queryString = url.split('?')[1] //获取查询字符串部分
2843 const regex = /([^=&]+)=([^&]*)/g //匹配键值对的正则表达式
2844 const params = {}
2845 let match
2846
2847 while ((match = regex.exec(queryString))) {
2848 const key = decodeURIComponent(match[1]) //解码键
2849 const value = decodeURIComponent(match[2]) //解码值
2850 params[key] = value //将键值对添加到对象中
2851 }
2852
2853 return params
2854}
2855// 请求
2856async function http(url, opts = {}) {
2857 const http_start = Date.now()

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected