nodebb-plugin-onekite-discord 1.0.10 → 1.0.11
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 +5 -22
- package/package.json +1 -1
- package/plugin.json +1 -1
package/library.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Normalize links for Discord embeds.
|
|
3
5
|
* Discord does NOT support masked links in embed descriptions.
|
|
@@ -17,12 +19,12 @@ function formatDiscordLinks(str) {
|
|
|
17
19
|
return url;
|
|
18
20
|
};
|
|
19
21
|
|
|
20
|
-
// HTML <a href>
|
|
22
|
+
// HTML <a href="...">...</a> -> URL
|
|
21
23
|
str = str.replace(/<a\s+[^>]*href=["']([^"']+)["'][^>]*>.*?<\/a>/gi, (_m, href) => {
|
|
22
24
|
return normalizeUrl(href);
|
|
23
25
|
});
|
|
24
26
|
|
|
25
|
-
// Markdown [text](url)
|
|
27
|
+
// Markdown [text](url) -> URL
|
|
26
28
|
str = str.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_m, _text, url) => {
|
|
27
29
|
return normalizeUrl(url);
|
|
28
30
|
});
|
|
@@ -35,25 +37,6 @@ function formatDiscordLinks(str) {
|
|
|
35
37
|
return str;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
'use strict';
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
;
|
|
43
|
-
|
|
44
|
-
// HTML links -> URL
|
|
45
|
-
str = str.replace(/<a\s+[^>]*href=["']([^"']+)["'][^>]*>(.*?)<\/a>/gi, (_m, href, _text) => {
|
|
46
|
-
return normalizeUrl(href);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// Markdown links [text](url) -> URL
|
|
50
|
-
str = str.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_m, _text, url) => {
|
|
51
|
-
return normalizeUrl(url);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return str;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
40
|
const { request } = require('undici');
|
|
58
41
|
|
|
59
42
|
const routeHelpers = require.main.require('./src/routes/helpers');
|
|
@@ -318,4 +301,4 @@ Plugin.onTopicReply = async (data) => {
|
|
|
318
301
|
await sendDiscord(settings.webhookUrl, { content: built.content, embeds: [built.embed] });
|
|
319
302
|
};
|
|
320
303
|
|
|
321
|
-
module.exports = Plugin;
|
|
304
|
+
module.exports = Plugin;
|
package/package.json
CHANGED
package/plugin.json
CHANGED