MCPcopy Create free account
hub / github.com/Rfym21/Qwen2API / parseAccountLine

Function parseAccountLine

src/utils/account-parser.js:19–40  ·  view source on GitHub ↗
(line)

Source from the content-addressed store, hash-verified

17 * @returns {{ email: string, password: string, proxy: string|null } | null} 解析失败返回 null
18 */
19const parseAccountLine = (line) => {
20 if (typeof line !== 'string') return null
21 const trimmed = line.trim()
22 if (!trimmed) return null
23
24 // 先按第一个 '|' 切出可选 proxy(proxy 部分自身可能含有 '|',例如 query 参数极少见,这里按首个分隔)
25 const pipeIdx = trimmed.indexOf('|')
26 const credentials = pipeIdx === -1 ? trimmed : trimmed.slice(0, pipeIdx)
27 const proxyRaw = pipeIdx === -1 ? '' : trimmed.slice(pipeIdx + 1)
28 const proxy = proxyRaw.trim() || null
29
30 // credentials 部分按第一个 ':' 切分,保留密码中可能存在的 ':'
31 const colonIdx = credentials.indexOf(':')
32 if (colonIdx === -1) return null
33
34 const email = credentials.slice(0, colonIdx).trim()
35 const password = credentials.slice(colonIdx + 1).trim()
36
37 if (!email || !password) return null
38
39 return { email, password, proxy }
40}
41
42module.exports = {
43 parseAccountLine

Callers 2

_loadFromEnvMethod · 0.85
parseBatchAccountsTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected