@openfn/language-common 1.6.0 → 1.6.1

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/ast.json CHANGED
@@ -903,7 +903,7 @@
903
903
  "str"
904
904
  ],
905
905
  "docs": {
906
- "description": "Subsitutes underscores for spaces and proper-cases a string",
906
+ "description": "Substitutes underscores for spaces and proper-cases a string",
907
907
  "tags": [
908
908
  {
909
909
  "title": "public",
@@ -941,12 +941,13 @@
941
941
  "valid": true
942
942
  },
943
943
  {
944
- "name": "removeEmojis",
944
+ "name": "scrubEmojis",
945
945
  "params": [
946
- "text"
946
+ "text",
947
+ "replacementChars"
947
948
  ],
948
949
  "docs": {
949
- "description": "Removes emojis from a string of text",
950
+ "description": "Replaces emojis in a string.",
950
951
  "tags": [
951
952
  {
952
953
  "title": "public",
@@ -955,7 +956,7 @@
955
956
  },
956
957
  {
957
958
  "title": "example",
958
- "description": "removeEmojis('Dove🕊️⭐ 29')"
959
+ "description": "scrubEmojis('Dove🕊️⭐ 29')"
959
960
  },
960
961
  {
961
962
  "title": "function",
@@ -971,6 +972,15 @@
971
972
  },
972
973
  "name": "text"
973
974
  },
975
+ {
976
+ "title": "param",
977
+ "description": "Characters that replace the emojis",
978
+ "type": {
979
+ "type": "NameExpression",
980
+ "name": "string"
981
+ },
982
+ "name": "replacementChars"
983
+ },
974
984
  {
975
985
  "title": "returns",
976
986
  "description": null,
package/lib/Adaptor.js CHANGED
@@ -26,7 +26,7 @@ exports.toArray = toArray;
26
26
  exports.composeNextState = composeNextState;
27
27
  exports.humanProper = humanProper;
28
28
  exports.splitKeys = splitKeys;
29
- exports.removeEmojis = removeEmojis;
29
+ exports.scrubEmojis = scrubEmojis;
30
30
  exports.http = exports.beta = exports.map = void 0;
31
31
 
32
32
  var _fp = require("lodash/fp");
@@ -533,7 +533,7 @@ function composeNextState(state, response) {
533
533
  };
534
534
  }
535
535
  /**
536
- * Subsitutes underscores for spaces and proper-cases a string
536
+ * Substitutes underscores for spaces and proper-cases a string
537
537
  * @public
538
538
  * @example
539
539
  * field("destination_string__c", humanProper(state.data.path_to_string))
@@ -569,18 +569,21 @@ function splitKeys(obj, keys) {
569
569
  }, [{}, {}]);
570
570
  }
571
571
  /**
572
- * Removes emojis from a string of text
572
+ * Replaces emojis in a string.
573
573
  * @public
574
574
  * @example
575
- * removeEmojis('Dove🕊️⭐ 29')
575
+ * scrubEmojis('Dove🕊️⭐ 29')
576
576
  * @function
577
577
  * @param {string} text - String that needs to be cleaned
578
+ * @param {string} replacementChars - Characters that replace the emojis
578
579
  * @returns {string}
579
580
  */
580
581
 
581
582
 
582
- function removeEmojis(text) {
583
+ function scrubEmojis(text, replacementChars) {
583
584
  if (!text) return text;
585
+ if (!replacementChars) replacementChars = '\uFFFD';
586
+ if (replacementChars == '') console.warn('Removing characters from a string may create injection vulnerabilities;', "It's better to replace than remove.", 'See https://www.unicode.org/reports/tr36/#Deletion_of_Noncharacters');
584
587
  const emojisPattern = /(\uFE0F|\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;
585
- return text.replace(emojisPattern, '');
588
+ return text.replace(emojisPattern, replacementChars);
586
589
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-common",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Common Expressions for OpenFn",
5
5
  "main": "lib/Adaptor.js",
6
6
  "scripts": {