@aipanel/dsh-client 1.2.1 → 1.2.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/client.js +5 -9
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -46,16 +46,12 @@ function serializeElement(ref) {
|
|
|
46
46
|
try {
|
|
47
47
|
const e = JSON.parse(ref);
|
|
48
48
|
if (!e || typeof e !== "object") throw new Error("not an element payload");
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
(m) => m === "/" ? "\uFF0F" : "\uFF3C"
|
|
52
|
-
);
|
|
49
|
+
const safe = (s) => s.replace(/[\\/]/g, (m) => m === "/" ? "\uFF0F" : "\uFF3C").replace(/["\n\r]+/g, " ");
|
|
50
|
+
const selector = safe(e.description || "element");
|
|
53
51
|
const text = e.innerText?.trim();
|
|
54
|
-
const textPreview = text ?
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
) : "";
|
|
58
|
-
return `@\u9009\u4E2D\u5143\u7D20:${selector}${textPreview ? `(${textPreview})` : ""}`;
|
|
52
|
+
const textPreview = text ? text.length > 5 ? text.slice(0, 5) + "..." : text : "";
|
|
53
|
+
const body = `\u9009\u4E2D\u5143\u7D20:${selector}${textPreview ? `(${safe(textPreview)})` : ""}`;
|
|
54
|
+
return `@"${body}"`;
|
|
59
55
|
} catch {
|
|
60
56
|
return `@${ref}`;
|
|
61
57
|
}
|