mezon-js 2.13.60 → 2.13.61

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.
@@ -715,11 +715,15 @@ function b64DecodeUnicode(str) {
715
715
  }
716
716
  function safeJSONParse(jsonStr) {
717
717
  try {
718
- const parsedData = JSON.parse(jsonStr);
719
- return parsedData;
718
+ return JSON.parse(jsonStr);
720
719
  } catch (error) {
721
720
  if (jsonStr !== "") {
722
- console.error("Error parsing JSON:", jsonStr, error);
721
+ const fixedJsonStr = jsonStr.replace(/\n/g, "\\n");
722
+ try {
723
+ return JSON.parse(fixedJsonStr);
724
+ } catch (e) {
725
+ console.error("Error parsing JSON:", jsonStr, error);
726
+ }
723
727
  }
724
728
  return { t: jsonStr };
725
729
  }
@@ -681,11 +681,15 @@ function b64DecodeUnicode(str) {
681
681
  }
682
682
  function safeJSONParse(jsonStr) {
683
683
  try {
684
- const parsedData = JSON.parse(jsonStr);
685
- return parsedData;
684
+ return JSON.parse(jsonStr);
686
685
  } catch (error) {
687
686
  if (jsonStr !== "") {
688
- console.error("Error parsing JSON:", jsonStr, error);
687
+ const fixedJsonStr = jsonStr.replace(/\n/g, "\\n");
688
+ try {
689
+ return JSON.parse(fixedJsonStr);
690
+ } catch (e) {
691
+ console.error("Error parsing JSON:", jsonStr, error);
692
+ }
689
693
  }
690
694
  return { t: jsonStr };
691
695
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mezon-js",
3
- "version": "2.13.60",
3
+ "version": "2.13.61",
4
4
  "scripts": {
5
5
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
6
6
  },
package/utils.ts CHANGED
@@ -50,11 +50,15 @@ export function b64DecodeUnicode(str: string) {
50
50
 
51
51
  export function safeJSONParse(jsonStr: string) {
52
52
  try {
53
- const parsedData = JSON.parse(jsonStr);
54
- return parsedData;
53
+ return JSON.parse(jsonStr);
55
54
  } catch (error) {
56
55
  if (jsonStr !== "") {
57
- console.error('Error parsing JSON:', jsonStr, error);
56
+ const fixedJsonStr = jsonStr.replace(/\n/g, "\\n");
57
+ try {
58
+ return JSON.parse(fixedJsonStr);
59
+ } catch (e) {
60
+ console.error('Error parsing JSON:', jsonStr, error);
61
+ }
58
62
  }
59
63
  return {t: jsonStr}; // Handle the error gracefully or throw an exception if necessary
60
64
  }