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

Function parseArguments

Rewrite-Parser.js:2394–2427  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

2392}
2393
2394function parseArguments(str) {
2395 if (/#!arguments/.test(str)) {
2396 const queryString = str.split(/#!arguments\s*=\s*/)[1] //获取查询字符串部分
2397 const regex = /([^:,]+):(\s*".+?"|[^,]*)/g //匹配键值对的正则表达式
2398 let match
2399
2400 while ((match = regex.exec(queryString))) {
2401 const key = match[1].trim().replace(/^"(.+)"$/, '$1') //去除头尾空白符和引号
2402 const value = match[2].trim().replace(/^"(.+)"$/, '$1') //去除头尾空白符和引号
2403 const type = /^(true|false)$/.test(value) ? 'switch' : 'input'
2404 const tag = `tag=${key}, desc=${key}`
2405
2406 sgArg.push({ key, value, type, tag }) //将键值对添加到对象中
2407
2408 if (value == 'hostname') {
2409 hn2 = true
2410 hn2name = '{{{' + key + '}}}'
2411 }
2412 }
2413 } else {
2414 const regex = /(^.*?)\s*=\s*(.*?)\s*,(.*?),\s*([^,]*\s*=.+)/ //获取信息
2415 const key = str.match(regex)[1]
2416 const type = str.match(regex)[2]
2417 const value = str.match(regex)[3]
2418 const tag = str.match(regex)[4]
2419
2420 sgArg.push({ key, value, type, tag })
2421
2422 if (value == 'hostname') {
2423 hn2 = true
2424 hn2name = '{{{' + key + '}}}'
2425 }
2426 }
2427}
2428
2429function parseQueryString(url) {
2430 const queryString = url.split('?')[1] //获取查询字符串部分

Callers 1

Rewrite-Parser.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected