Files
crawler-plugin/frontend-vue/tests/青果账密拼提取链接.test.ts
T
huangzd1997 faae355bcf fix(user-secret): 青果只用 Authkey/Authpwd,链接由前端拼并上报服务端
青果没有可填的提取链接(10-30 口径),但商标检测在服务端只认 proxy_url,
保存时又主动清空服务端记录 ⇒ 用户填了账密仍被判「未配置代理」。
- 新增 qingguo-link.ts(零依赖):由账密拼 overseas.proxy.qg.net/get 链接,
  Authkey/Authpwd 走 userinfo(隧道 Basic 认证没有第二个通道)
- 保存时本地与服务端都用这条链接;已存账密的旧配置刷新后仍能读回
- 4 例纯函数用例钉住拼装规则与空 key 语义
2026-10-31 22:16:30 +08:00

30 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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)
})