import { test } from 'node:test' import assert from 'node:assert/strict' import { composeQingguoLink, QINGGUO_EXTRACT_URL } from '../src/shared/utils/qingguo-link.ts' /** * 青果没有「提取链接」可填,用户只给 Authkey/Authpwd,链接必须由前端拼出来 * (2026-10-31 用户拍板)。拼不出来或拼错,用户就会在「填了账密」之后仍被 * 商标检测的前置检查判成「未配置代理」——这正是 2026-10-31 用户报的那个问题。 */ test('青果只有 Authkey 时拼出带 key 的提取链接', () => { const link = composeQingguoLink(' 40F79A90 ', '') assert.equal(link, `${QINGGUO_EXTRACT_URL}?key=40F79A90&format=json`) }) test('青果 Authkey+Authpwd 必须把账密放进 userinfo(隧道 Basic 认证没有第二个通道)', () => { const link = composeQingguoLink('40F79A90', 'Sec@ret:1') assert.ok(link.startsWith('https://40F79A90:Sec%40ret%3A1@overseas.proxy.qg.net/get?'), link) assert.ok(link.endsWith('&format=json'), link) }) test('没填 Authkey 就不拼链接(空串=没配置,不许拼一条必然失败的链接)', () => { assert.equal(composeQingguoLink('', 'pwd'), '') assert.equal(composeQingguoLink(' ', 'pwd'), '') }) test('key 里的特殊字符要编码,不能把查询串拼坏', () => { const link = composeQingguoLink('a&b=c', '') assert.ok(link.endsWith('?key=a%26b%3Dc&format=json'), link) })