@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.
@@ -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* or _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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heliyos/heliyos-api-core",
3
- "version": "1.0.68",
3
+ "version": "1.0.69",
4
4
  "description": "Heliyos's core api functions and middlewares. Its a private package hosted on npm.",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -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* or _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