feat(web): connect quick share flow

Signed-off-by: JustMe <mr.toing@outlook.com>
This commit is contained in:
justme committed 2026-10-02 00:59:37 +08:00
1 parent 53768a195d
commit e02e024605
138 files changed
+10614

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import { describe, expect, it } from 'vitest';
import { parseShareLink } from './shareLink';
const ID = 'k3Fq9xWm2LpA7sTdQ8vZ1n';
const KEY = 'Zm9vYmFyYmF6cXV4Zm9vYmFyYmF6cXV4Zm9vYmFyYmF';
describe('parseShareLink', () => {
it('解析访客链接', () => {
expect(parseShareLink(`https://webdrop.example/s/${ID}#k=${KEY}`)).toEqual({ ok: true, link: { id: ID, key: KEY } });
});
it('忽略首尾空白', () => {
expect(parseShareLink(` https://x.example/s/${ID}#k=${KEY} `).ok).toBe(true);
});
it.each([
['不是链接', 'hello', 'bad_url'],
['频道链接不是分享链接', `https://x.example/c/${ID}#k=${KEY}`, 'bad_url'],
['id 长度不对', `https://x.example/s/abc#k=${KEY}`, 'bad_id'],
['缺少密钥', `https://x.example/s/${ID}`, 'bad_key'],
['密钥长度不对', `https://x.example/s/${ID}#k=short`, 'bad_key'],
])('%s → %s', (_n, input, error) => {
expect(parseShareLink(input)).toEqual({ ok: false, error });
});
});