fix(api): 升级行情解析器正则规则,兼容 BRK.B 等包含特殊字符的股票代码

This commit is contained in:
2026-05-01 23:35:31 +08:00
parent f059aeb08f
commit 9ff48f37d1
3 changed files with 10 additions and 4 deletions
+2 -2
View File
@@ -31,7 +31,7 @@ function parseMarketDate(rawString: string): string {
}
async function fetchStockPrice(asset: { symbol: string; exchange: string | null }): Promise<{ price: string | null; rawResponse: string | null }> {
const cleanSymbol = asset.symbol.trim().toUpperCase().replace(/[^0-9A-Z]/g, '');
const cleanSymbol = asset.symbol.trim().toUpperCase().replace(/[^0-9A-Z.\-]/g, '');
let tCode: string;
switch (asset.exchange) {
@@ -50,7 +50,7 @@ async function fetchStockPrice(asset: { symbol: string; exchange: string | null
break;
}
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);