feat(framework): config H5 URL query 身份来源

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-28 16:33:58 +08:00
co-authored by Claude Opus 4.8
parent 2f97150a6f
commit 510c074627
2 changed files with 35 additions and 0 deletions
@@ -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' });
});