fix: normalize Web stock identity width

This commit is contained in:
ZhuLinsen
2026-08-29 22:30:20 +08:00
parent 3f87a9418f
commit 63c9eddd3b
2 changed files with 9 additions and 1 deletions

View File

@@ -70,6 +70,14 @@ describe('entityLink helpers', () => {
expect(link.ref).toBe('stock:CN:600519');
});
it.each([
['', 'cn', 'stock:CN:600519'],
['', 'hk', 'stock:HK:HK00700'],
['', 'us', 'stock:US:AAPL'],
])('normalizes full-width stock code %s before Web identity validation', (code, market, ref) => {
expect(buildStockEntityLink(code, market).ref).toBe(ref);
});
it('accepts longer canonical US symbols from the checked-in stock index', () => {
const link = buildStockEntityLink('AAICPRC', 'us');

View File

@@ -178,7 +178,7 @@ const splitMarketEntityId = (entityId: string): [string, string] => {
const normalizeEntityId = (entityType: EntityType, entityId: string): string => {
const normalizedId = String(entityId).trim();
if (entityType !== 'stock') return normalizedId;
return normalizeStockEntityId(normalizedId);
return normalizeStockEntityId(normalizedId.normalize('NFKC'));
};
const normalizeStockEntityId = (entityId: string): string => {