fix: 修复 VikaACG 搜索结果中的 Unicode 转义字符

* 解决 VikaACG 平台搜索结果中 `\uXXXX` Unicode 转义字符未正确解码的问题。
* 新增逻辑将 `\uXXXX` 转义序列转换为实际字符,确保搜索结果内容正确显示。
This commit is contained in:
Jurangren
2025-08-23 03:29:01 +08:00
parent 9015c54201
commit eed68a9a4d

View File

@@ -49,7 +49,10 @@ async function searchVikaACG(game: string): Promise<PlatformSearchResult> {
// .json() will parse the JSON and unescape the string content.
const html: string = await response.text();
const matches = html.replaceAll('\\/', '/').replaceAll('\\\\', '\\').replaceAll('\\"', '"').matchAll(REGEX);
const decodedHtml = html.replaceAll('\\/', '/').replaceAll('\\\\', '\\').replaceAll('\\"', '"').replace(/\\u([\d\w]{4})/gi, (match, grp) => {
return String.fromCharCode(parseInt(grp, 16));
});
const matches = decodedHtml.matchAll(REGEX);
const items: SearchResultItem[] = [];
for (const match of matches) {