@sns-parse/core 0.6.0-alpha.2 → 0.6.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/utils/url.js +13 -5
- package/package.json +1 -1
package/lib/utils/url.js
CHANGED
|
@@ -50,11 +50,16 @@ function extractAllUrlsFromMessage(session, rules) {
|
|
|
50
50
|
const cardsContent = [];
|
|
51
51
|
if (session.elements) {
|
|
52
52
|
for (const elem of session.elements) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
// Koishi 元素属性在 elem.attrs(onebot json/xml 分享卡:h.json/h.xml → attrs.data)
|
|
54
|
+
const data = elem.attrs?.data ?? elem.data;
|
|
55
|
+
if (typeof data !== 'string' || !data)
|
|
56
|
+
continue;
|
|
57
|
+
if (elem.type === 'xml') {
|
|
58
|
+
cardsContent.push(data);
|
|
59
|
+
}
|
|
60
|
+
else if (elem.type === 'json') {
|
|
56
61
|
try {
|
|
57
|
-
const json = JSON.parse(
|
|
62
|
+
const json = JSON.parse(data);
|
|
58
63
|
const extract = (obj) => {
|
|
59
64
|
if (!obj || typeof obj !== 'object')
|
|
60
65
|
return;
|
|
@@ -67,7 +72,10 @@ function extractAllUrlsFromMessage(session, rules) {
|
|
|
67
72
|
};
|
|
68
73
|
extract(json);
|
|
69
74
|
}
|
|
70
|
-
catch {
|
|
75
|
+
catch {
|
|
76
|
+
// 非 JSON 文本仍按原文扫一遍
|
|
77
|
+
cardsContent.push(data);
|
|
78
|
+
}
|
|
71
79
|
}
|
|
72
80
|
}
|
|
73
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sns-parse/core",
|
|
3
|
-
"version": "0.6.0-alpha.
|
|
3
|
+
"version": "0.6.0-alpha.3+upstream.1.6.7",
|
|
4
4
|
"description": "sns-parse 核心:契约、宿主抽象、配置 DSL 与解析引擎(fetcher/parser/翻译/X 原生解析/合并/GIF/TLS 指纹客户端)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|