fix: 修复 雪球类型和网易类型搜索股票代码未 URL 编码

This commit is contained in:
zhangxiangliang 2020-08-21 02:07:00 +08:00
parent 347b508917
commit 67914d5cdf
2 changed files with 2 additions and 2 deletions

View File

@ -74,7 +74,7 @@ const Netease: StockApi = {
*/
async searchStocks(key: string): Promise<Stock[]> {
// 数据获取
const url = `https://quotes.money.163.com/stocksearch/json.do?type=&count=5&word=${key}&callback=topstock`;
const url = `https://quotes.money.163.com/stocksearch/json.do?type=&count=5&word=${encodeURIComponent(key)}&callback=topstock`;
const res = await fetch.get(url);
// 解析数据

View File

@ -93,7 +93,7 @@ const Xueqiu: StockApi & { getToken(): Promise<string> } = {
const token = await this.getToken();
// 数据获取
const url = `https://xueqiu.com/stock/search.json?code=${key}`;
const url = `https://xueqiu.com/stock/search.json?code=${encodeURIComponent(key)}`;
const res = await fetch.get(url).set('Cookie', token);
const body = JSON.parse(res.text);