fix(api): 升级行情解析器正则规则,兼容 BRK.B 等包含特殊字符的股票代码
This commit is contained in:
@@ -8,7 +8,7 @@ import { revalidatePath } from 'next/cache';
|
||||
import { onConflictDoUpdate } from 'drizzle-orm/pg-core';
|
||||
|
||||
function getTencentSymbol(asset: { symbol: string; exchange: string | null }): string {
|
||||
const cleanSymbol = asset.symbol.trim().toUpperCase().replace(/[^0-9A-Z]/g, '');
|
||||
const cleanSymbol = asset.symbol.trim().toUpperCase().replace(/[^0-9A-Z.\-]/g, '');
|
||||
|
||||
switch (asset.exchange) {
|
||||
case 'SSE': return 'sh' + cleanSymbol;
|
||||
@@ -36,7 +36,7 @@ export async function syncAllMarketPrices() {
|
||||
try {
|
||||
if (asset.type === 'STOCK') {
|
||||
const tCode = getTencentSymbol(asset);
|
||||
const response = await fetch(`https://qt.gtimg.cn/q=${tCode}`, { cache: 'no-store' });
|
||||
const response = await fetch(`https://sqt.gtimg.cn/q=${tCode}`, { cache: 'no-store' });
|
||||
const arrayBuffer = await response.arrayBuffer();
|
||||
const decoder = new TextDecoder('gbk');
|
||||
const text = decoder.decode(arrayBuffer);
|
||||
|
||||
Reference in New Issue
Block a user