nodebb-plugin-onekite-discord 1.0.6 → 1.0.7

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/library.js CHANGED
@@ -41,6 +41,26 @@ function ensureAbsoluteUrl(baseUrl, maybeUrl) {
41
41
  return s;
42
42
  }
43
43
 
44
+
45
+ function normalizeExcerptLinks(input) {
46
+ if (!input) return '';
47
+ let s = String(input);
48
+
49
+ // Convert HTML anchors to "text (url)" before stripping HTML
50
+ s = s.replace(/<a\s+[^>]*href=["']([^"']+)["'][^>]*>([\s\S]*?)<\/a>/gi, (m, href, inner) => {
51
+ const text = stripHtml(inner).trim() || href;
52
+ return `${text} (${href})`;
53
+ });
54
+
55
+ // Convert Markdown links [text](url) to "text (url)"
56
+ s = s.replace(/\[([^\]]+)\]\(([^\s)]+)\)/g, (m, label, url) => `${label} (${url})`);
57
+
58
+ // Fix common malformed scheme "https:/example.com" -> "https://example.com"
59
+ s = s.replace(/\b(https?):\/(?!\/)/g, '$1://');
60
+
61
+ return s;
62
+ }
63
+
44
64
  function stripHtml(html) {
45
65
  if (!html) return '';
46
66
  return String(html)
@@ -142,7 +162,8 @@ async function getPostExcerpt(pid) {
142
162
  if (!pid) return '';
143
163
  try {
144
164
  const p = await posts.getPostFields(pid, ['content']);
145
- const text = stripHtml(p && p.content);
165
+ const normalized = normalizeExcerptLinks(p && p.content);
166
+ const text = stripHtml(normalized);
146
167
  return truncate(text, 500);
147
168
  } catch {
148
169
  return '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-onekite-discord",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Discord webhook notifier for Onekite (NodeBB v4.x only)",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/plugin.json CHANGED
@@ -31,5 +31,5 @@
31
31
  "acpScripts": [
32
32
  "public/admin.js"
33
33
  ],
34
- "version": "1.0.6"
34
+ "version": "1.0.7"
35
35
  }