feat(framework): config H5 URL query 身份来源
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { queryStringSource } from '../../../YouleNexus/assets/framework/config/sources/query-string.ts';
|
||||
|
||||
test('解析 agentid/channelid/marketid/version', () => {
|
||||
const src = queryStringSource('?agentid=A1&channelid=C1&marketid=2&version=9.9');
|
||||
assert.deepEqual(src(), { agentid: 'A1', channelid: 'C1', marketid: '2', version: '9.9' });
|
||||
});
|
||||
|
||||
test('缺省键不出现在结果里', () => {
|
||||
const src = queryStringSource('?agentid=A1');
|
||||
assert.deepEqual(src(), { agentid: 'A1' });
|
||||
});
|
||||
|
||||
test('空 query → 空对象', () => {
|
||||
assert.deepEqual(queryStringSource('')(), {});
|
||||
});
|
||||
|
||||
test('不含前导 ? 也能解析', () => {
|
||||
assert.deepEqual(queryStringSource('agentid=A1')(), { agentid: 'A1' });
|
||||
});
|
||||
Reference in New Issue
Block a user