mirror of
https://github.com/ZhuLinsen/daily_stock_analysis
synced 2026-09-20 10:53:33 +08:00
fix: normalize Web stock identity width
This commit is contained in:
@@ -70,6 +70,14 @@ describe('entityLink helpers', () => {
|
||||
expect(link.ref).toBe('stock:CN:600519');
|
||||
});
|
||||
|
||||
it.each([
|
||||
['600519', 'cn', 'stock:CN:600519'],
|
||||
['700', 'hk', 'stock:HK:HK00700'],
|
||||
['AAPL', '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');
|
||||
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user