fix: accept qdreader json map cookie input

This commit is contained in:
2026-05-17 17:58:01 +08:00
parent c040ca40df
commit 9d8021e1e4
3 changed files with 83 additions and 18 deletions
+9
View File
@@ -73,6 +73,15 @@ test('manual cookie save falls back to ywguid when QDHeader uid is null', () =>
assert.equal(JSON.parse(r.store.qdreader_cookie_json)['54321'], fallbackCookie);
});
test('manual cookie save accepts upstream JSON map format', () => {
const jsonCookie = 'QDHeader=KG51bGwpfHg=; ywguid=54321; qdh=qdh; sessionyw=s; appId=10';
const r = runPlugin({ content: '启点ck ' + JSON.stringify({ '475700975': jsonCookie }) });
assert.match(r.replies.join('\n'), /CK新增成功/);
assert.match(r.replies.join('\n'), /uid: 475700975/);
assert.equal(JSON.parse(r.store.qdreader_cookie_json)['475700975'], jsonCookie);
assert.equal(JSON.parse(r.bucketStore['hermes_qidian.qdreader_user_bind_json'])['475700975'], 'user-a');
});
test('manual cookie save falls back to QDHeader embedded UserId before ywguid', () => {
const streamQdheader = 'KG51bGwpfChudWxsKXwxMTc5fDI1NTZ8KG51bGwpfDE2LjEwfDB8aU9TL2lQaG9uZS8obnVsbCl8MHwobnVsbCl8KG51bGwpfDQ3NTcwMDk3NXwxNzc5MDA5MTM2MDAwfDB8KG51bGwpfHx8KG51bGwpfChudWxsKXww';
const streamCookie = `QDHeader=${streamQdheader}; ywguid=120098575768; qdh=qdh; sessionyw=s; appId=12`;