fix(claim): 统一所有买家领取链接为 H5 订单号格式

This commit is contained in:
yml2213
2026-11-02 22:11:22 +08:00
parent 3989b0a649
commit 4dc2f5ca90
38 changed files with 298 additions and 362 deletions
+17 -9
View File
@@ -89,22 +89,30 @@ test('describeMissingConfigFields:缺单项只返回对应中文名', () => {
)
})
test('领取链接预览 = 基址去尾斜杠 + token', () => {
test('领取链接预览统一为 /h5/订单号', () => {
assert.equal(
buildDouyinMashidaClaimLinkPreview('https://x.ngrok-free.app/claim', 'tok123'),
'https://x.ngrok-free.app/claim/tok123',
buildDouyinMashidaClaimLinkPreview('https://x.ngrok-free.app/claim', '6919156612984680391'),
'https://x.ngrok-free.app/h5/6919156612984680391',
)
// 尾斜杠与前后空格要容忍
assert.equal(
buildDouyinMashidaClaimLinkPreview(' https://x.example.com/claim/ ', 'tok123'),
'https://x.example.com/claim/tok123',
buildDouyinMashidaClaimLinkPreview(' https://x.example.com/h5/ ', '6919156612984680391'),
'https://x.example.com/h5/6919156612984680391',
)
// 裸域名也允许(后端统一补 /token)
// 裸域名和历史 hash 基址都归一化为 /h5
assert.equal(
buildDouyinMashidaClaimLinkPreview('https://x.example.com', 'tok123'),
'https://x.example.com/tok123',
buildDouyinMashidaClaimLinkPreview('https://x.example.com', '6919156612984680391'),
'https://x.example.com/h5/6919156612984680391',
)
// 留空 → 不生成链接(后端回退到通用兑换链接)
assert.equal(
buildDouyinMashidaClaimLinkPreview('https://x.example.com/#/claim', '6919156612984680391'),
'https://x.example.com/h5/6919156612984680391',
)
assert.equal(
buildDouyinMashidaClaimLinkPreview('https://x.example.com/claim/tok123', '6919156612984680391'),
'https://x.example.com/h5/6919156612984680391',
)
// 留空 → 不生成预览
assert.equal(buildDouyinMashidaClaimLinkPreview(''), '')
assert.equal(buildDouyinMashidaClaimLinkPreview(' '), '')
})