浏览代码

ignore broken unnamed pi fields

Markus-Rost 4 年之前
父节点
当前提交
7c3e537ea8
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      util/functions.js

+ 3 - 1
util/functions.js

@@ -34,10 +34,12 @@ function parse_infobox(infobox, embed, thumbnail, pagelink = '') {
 			label = htmlToPlain(label).trim();
 			label = htmlToPlain(label).trim();
 			value = htmlToDiscord(value, pagelink, true).trim();
 			value = htmlToDiscord(value, pagelink, true).trim();
 			if ( label.includes( '*UNKNOWN LINK*' ) ) {
 			if ( label.includes( '*UNKNOWN LINK*' ) ) {
+				if ( !( source || name ) ) break;
 				label = '`' + ( source || name )  + '`';
 				label = '`' + ( source || name )  + '`';
 				embed.brokenInfobox = true;
 				embed.brokenInfobox = true;
 			}
 			}
 			if ( value.includes( '*UNKNOWN LINK*' ) ) {
 			if ( value.includes( '*UNKNOWN LINK*' ) ) {
+				if ( !( source || name ) ) break;
 				value = '`' + ( source || name ) + '`';
 				value = '`' + ( source || name ) + '`';
 				embed.brokenInfobox = true;
 				embed.brokenInfobox = true;
 			}
 			}
@@ -359,7 +361,7 @@ function escapeFormatting(text = '', isMarkdown = false, keepLinks = false) {
 function limitLength(text = '', limit = 1000, maxExtra = 20) {
 function limitLength(text = '', limit = 1000, maxExtra = 20) {
 	var suffix = '\u2026';
 	var suffix = '\u2026';
 	var link = null;
 	var link = null;
-	var regex = /(?<!\\)\[((?:[^\[\]]|\\[\[\]])+?[^\\])\]\((?:[^()]|\\[()])+?[^\\]\)/g;
+	var regex = /(?<!\\)\[((?:[^\[\]]|\\[\[\]])+?[^\\])\]\(<?(?:[^()]|\\[()])+?>?[^\\]\)/g;
 	while ( ( link = regex.exec(text) ) !== null ) {
 	while ( ( link = regex.exec(text) ) !== null ) {
 		if ( link.index < limit && link.index + link[0].length > limit ) {
 		if ( link.index < limit && link.index + link[0].length > limit ) {
 			limit = link.index;
 			limit = link.index;