@heliyos/heliyos-api-core 1.0.68 → 1.0.69
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/dist/email/index.js +5 -2
- package/package.json +1 -1
- package/src/email/index.ts +6 -2
package/dist/email/index.js
CHANGED
|
@@ -52,12 +52,12 @@ const markdownToHtml = (text) => {
|
|
|
52
52
|
// Bold: **text** or __text__
|
|
53
53
|
.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>")
|
|
54
54
|
.replace(/__(.*?)__/g, "<strong>$1</strong>")
|
|
55
|
-
// Italics: *text*
|
|
55
|
+
// Italics: *text* (intentionally avoid _text_ to keep URLs/query keys intact)
|
|
56
56
|
.replace(/\*(.*?)\*/g, "<em>$1</em>")
|
|
57
|
-
.replace(/_(.*?)_/g, "<em>$1</em>")
|
|
58
57
|
// Newlines to <br>
|
|
59
58
|
.replace(/\n/g, "<br>");
|
|
60
59
|
};
|
|
60
|
+
const URL_LIKE_PATTERN = /^(https?:\/\/|mailto:|tel:)\S+$/i;
|
|
61
61
|
/**
|
|
62
62
|
* Recursively process object values to convert markdown to HTML
|
|
63
63
|
*/
|
|
@@ -65,6 +65,9 @@ const processMarkdownData = (data) => {
|
|
|
65
65
|
if (!data)
|
|
66
66
|
return data;
|
|
67
67
|
if (typeof data === "string") {
|
|
68
|
+
if (URL_LIKE_PATTERN.test(data.trim())) {
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
68
71
|
return markdownToHtml(data);
|
|
69
72
|
}
|
|
70
73
|
if (Array.isArray(data)) {
|
package/package.json
CHANGED
package/src/email/index.ts
CHANGED
|
@@ -25,13 +25,14 @@ const markdownToHtml = (text: string): string => {
|
|
|
25
25
|
// Bold: **text** or __text__
|
|
26
26
|
.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>")
|
|
27
27
|
.replace(/__(.*?)__/g, "<strong>$1</strong>")
|
|
28
|
-
// Italics: *text*
|
|
28
|
+
// Italics: *text* (intentionally avoid _text_ to keep URLs/query keys intact)
|
|
29
29
|
.replace(/\*(.*?)\*/g, "<em>$1</em>")
|
|
30
|
-
.replace(/_(.*?)_/g, "<em>$1</em>")
|
|
31
30
|
// Newlines to <br>
|
|
32
31
|
.replace(/\n/g, "<br>");
|
|
33
32
|
};
|
|
34
33
|
|
|
34
|
+
const URL_LIKE_PATTERN = /^(https?:\/\/|mailto:|tel:)\S+$/i;
|
|
35
|
+
|
|
35
36
|
/**
|
|
36
37
|
* Recursively process object values to convert markdown to HTML
|
|
37
38
|
*/
|
|
@@ -39,6 +40,9 @@ const processMarkdownData = (data: any): any => {
|
|
|
39
40
|
if (!data) return data;
|
|
40
41
|
|
|
41
42
|
if (typeof data === "string") {
|
|
43
|
+
if (URL_LIKE_PATTERN.test(data.trim())) {
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
42
46
|
return markdownToHtml(data);
|
|
43
47
|
}
|
|
44
48
|
|