@@ -28,13 +28,11 @@ interface LinkType {
2828 * @returns 替换后的字符串
2929 */
3030function parse_little_app ( content : string ) : string {
31- // 正则匹配完整的 <json> 标签,包括 data 属性和结束符 />
3231 const jsonRegex = / < j s o n \s + d a t a = " ( [ ^ " ] + ) " \s * \/ ? > / g;
3332
3433 // 使用 replace 方法直接替换原文
3534 const replacedContent = content . replace ( jsonRegex , ( match , p1 ) => {
3635 try {
37- // 解码 HTML 实体并解析 JSON 数据
3836 const jsonData = JSON . parse (
3937 p1
4038 . replace ( / & q u o t ; / g, '"' ) // 替换 HTML 实体
@@ -43,15 +41,12 @@ function parse_little_app(content: string): string {
4341
4442 // 检查是否包含符合条件的 appid
4543 if ( jsonData . meta ?. detail_1 ?. appid === "1109937557" ) {
46- // 返回链接替换原来的 <json> 标签
4744 return jsonData . meta . detail_1 . qqdocurl || match ;
4845 }
4946
50- // 如果条件不满足,保留原来的 <json> 标签
5147 return match ;
5248 } catch ( error ) {
53- console . error ( "Failed to parse JSON:" , error ) ;
54- // 如果解析失败,保留原来的 <json> 标签
49+ logger . error ( "Failed to parse little app JSON:" , error ) ;
5550 return match ;
5651 }
5752 } ) ;
@@ -68,13 +63,20 @@ function parse_little_app(content: string): string {
6863function link_type_parser ( content : string , config : Config ) : LinkType [ ] {
6964 const linkRegex : LinkRegex [ ] = [ ] ;
7065
71- if ( config . bVideoEnable )
66+ if ( config . bVideoEnable ) {
7267 linkRegex . push ( {
7368 pattern : config . bVideoFullURL
74- ? / b i l i b i l i \. c o m \/ v i d e o \/ ( [ a b ] v [ 0 - 9 a - z A - Z ] + ) / gim
75- : / ( [ a b ] v [ 0 - 9 a - z A - Z ] + ) / gim,
69+ ? / b i l i b i l i \. c o m \/ v i d e o \/ (?< ! [ a - z A - Z 0 - 9 ] ) [ a A ] [ v V ] ( [ 0 - 9 ] + ) / gim
70+ : / ( (?< ! [ a - z A - Z 0 - 9 ] ) [ a A ] [ v V ] ( [ 0 - 9 ] + ) ) / gim,
7671 type : "Video" ,
7772 } ) ;
73+ linkRegex . push ( {
74+ pattern : config . bVideoFullURL
75+ ? / b i l i b i l i \. c o m \/ v i d e o \/ (?< ! [ a - z A - Z 0 - 9 ] ) [ b B ] [ v V ] ( 1 [ 0 - 9 A - Z a - z ] + ) / gim
76+ : / ( (?< ! [ a - z A - Z 0 - 9 ] ) [ b B ] [ v V ] ( 1 [ 0 - 9 A - Z a - z ] + ) ) / gim,
77+ type : "Video" ,
78+ } ) ;
79+ }
7880
7981 if ( config . bLiveEnable )
8082 linkRegex . push ( {
@@ -164,7 +166,7 @@ function link_type_parser(content: string, config: Config): LinkType[] {
164166 }
165167
166168 let sanitizedContent : string = content ;
167- sanitizedContent = parse_little_app ( sanitizedContent )
169+ sanitizedContent = parse_little_app ( sanitizedContent ) ;
168170 sanitizedContent = sanitizedContent . replace ( / < [ ^ > ] + > / g, "" ) ;
169171 logger . debug ( "Sanitized message: " , sanitizedContent ) ;
170172
0 commit comments