fix(api): 升级行情解析器正则规则,兼容 BRK.B 等包含特殊字符的股票代码
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user