(str)
| 2796 | } |
| 2797 | |
| 2798 | function parseArguments(str) { |
| 2799 | if (/#!arguments/.test(str)) { |
| 2800 | const queryString = str.split(/#!arguments\s*=\s*/)[1] //获取查询字符串部分 |
| 2801 | const items = splitTopLevel(queryString, ',') |
| 2802 | |
| 2803 | for (let i = 0; i < items.length; i++) { |
| 2804 | const [rawKey, rawValue] = splitFirstTopLevel(items[i], ':') |
| 2805 | if (!rawKey || !rawValue) continue |
| 2806 | const key = stripWrapQuote(rawKey) |
| 2807 | const value = rawValue.trim() |
| 2808 | const type = /^(true|false)$/i.test(stripWrapQuote(value)) ? 'switch' : 'input' |
| 2809 | const tag = `tag=${key}, desc=${key}` |
| 2810 | |
| 2811 | sgArg.push({ key, value, type, tag }) //将键值对添加到对象中 |
| 2812 | |
| 2813 | if (stripWrapQuote(value) == 'hostname') { |
| 2814 | hn2 = true |
| 2815 | hn2name = '{{{' + key + '}}}' |
| 2816 | } |
| 2817 | } |
| 2818 | } else { |
| 2819 | const matched = str.match(/^([^=]+?)\s*=\s*(.+)$/) |
| 2820 | if (!matched) return |
| 2821 | const rawKey = matched[1] |
| 2822 | const rawRest = matched[2] |
| 2823 | const parts = splitTopLevel(rawRest, ',') |
| 2824 | const key = rawKey.trim() |
| 2825 | const type = parts.shift() |
| 2826 | const tagIndex = parts.findIndex(item => /^\s*(?:tag|desc)\s*=/.test(item)) |
| 2827 | const valueParts = tagIndex === -1 ? parts : parts.slice(0, tagIndex) |
| 2828 | const tagParts = tagIndex === -1 ? [] : parts.slice(tagIndex) |
| 2829 | const value = type == 'select' ? valueParts[0] : valueParts.join(',') |
| 2830 | const tag = tagParts.join(', ') || `tag=${key}, desc=${key}` |
| 2831 | |
| 2832 | sgArg.push({ key, value, type, tag }) |
| 2833 | |
| 2834 | if (stripWrapQuote(value) == 'hostname') { |
| 2835 | hn2 = true |
| 2836 | hn2name = '{{{' + key + '}}}' |
| 2837 | } |
| 2838 | } |
| 2839 | } |
| 2840 | |
| 2841 | function parseQueryString(url) { |
| 2842 | const queryString = url.split('?')[1] //获取查询字符串部分 |
no test coverage detected