(exportCookie: string)
| 36 | |
| 37 | // 解析导出cookie表达式生成导出的cookie |
| 38 | export function parseExportCookie(exportCookie: string): Promise<ExportCookies[]> { |
| 39 | const lines = exportCookie.split("\n"); |
| 40 | const result = []; |
| 41 | for (let i = 0; i < lines.length; i += 1) { |
| 42 | const line = lines[i]; |
| 43 | const detail: ExportCookies = {}; |
| 44 | if (line.trim()) { |
| 45 | for (const param of line.split(";")) { |
| 46 | const s = param.split("="); |
| 47 | if (s.length !== 2) { |
| 48 | continue; |
| 49 | } |
| 50 | detail[s[0].trim()] = s[1].trim(); |
| 51 | } |
| 52 | if (detail.url || detail.domain) { |
| 53 | result.push( |
| 54 | new Promise<ExportCookies>((resolve) => { |
| 55 | getCookies(detail).then((cookies) => { |
| 56 | detail.cookies = cookies; |
| 57 | resolve(detail); |
| 58 | }); |
| 59 | }) |
| 60 | ); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | return Promise.all(result); |
| 65 | } |
| 66 | |
| 67 | // 解析value表达式生成导出的value |
| 68 | export async function parseExportValue(script: Script, exportValue: string): Promise<Value[]> { |
no test coverage detected