@itentialopensource/adapter-utils 4.48.8 → 4.48.9

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/CHANGELOG.md CHANGED
@@ -1,4 +1,14 @@
1
1
 
2
+ ## 4.48.9 [03-23-2023]
3
+
4
+ * Add logic to strip escapes from the request body
5
+
6
+ Closes ADAPT-2611
7
+
8
+ See merge request itentialopensource/adapter-utils!249
9
+
10
+ ---
11
+
2
12
  ## 4.48.8 [03-09-2023]
3
13
 
4
14
  * Mask sensitive fields in reqHdr
@@ -22,7 +22,7 @@ let globalRequestGl = null;
22
22
  let returnRawGl = false;
23
23
  let encodePath = true;
24
24
  let encodeUri = true;
25
-
25
+ let stripEscapes = false;
26
26
  // INTERNAL FUNCTIONS
27
27
  /*
28
28
  * INTERNAL FUNCTION: Get the best match for the mock data response
@@ -967,7 +967,13 @@ function buildPayload(entity, action, entitySchema, payload) {
967
967
  return '';
968
968
  }
969
969
  }
970
-
970
+ // strip escapes if payload is double escaped
971
+ if (stripEscapes && systemEntity) {
972
+ let newPayload = JSON.stringify(systemEntity);
973
+ newPayload = newPayload.replace(/\\\\/g, '\\');
974
+ log.debug(`STRIPPED BODY HERE: ${newPayload}`);
975
+ return newPayload;
976
+ }
971
977
  // return the payload
972
978
  return JSON.stringify(systemEntity);
973
979
  } catch (e) {
@@ -1021,6 +1027,11 @@ class RestHandler {
1021
1027
  this.encodeQ = properties.encode_queryvars;
1022
1028
  encodeUri = this.encodeQ;
1023
1029
 
1030
+ // optional to strip extra escapes - default is false
1031
+ if (properties.stripEscapes) {
1032
+ stripEscapes = properties.stripEscapes;
1033
+ }
1034
+
1024
1035
  // only need to set returnRaw if the property is true - defaults to false
1025
1036
  if (properties.request && properties.request.return_raw) {
1026
1037
  returnRawGl = properties.request.return_raw;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itentialopensource/adapter-utils",
3
- "version": "4.48.8",
3
+ "version": "4.48.9",
4
4
  "description": "Itential Adapter Utility Libraries",
5
5
  "scripts": {
6
6
  "postinstall": "node utils/setup.js",