web-manager 3.1.10 → 3.1.11

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.
Files changed (2) hide show
  1. package/lib/utilities.js +21 -3
  2. package/package.json +2 -2
package/lib/utilities.js CHANGED
@@ -1,12 +1,23 @@
1
1
  /*
2
2
  */
3
3
 
4
+ var htmlEscapeMap = {
5
+ '&': '&',
6
+ '<': '&lt;',
7
+ '>': '&gt;',
8
+ '"': '&quot;',
9
+ "'": '&#39;',
10
+ '/': '&#x2F;',
11
+ '`': '&#x60;',
12
+ '=': '&#x3D;'
13
+ };
14
+
4
15
  function Utilities(utilObj) {
5
16
  this.utilities = utilObj;
6
17
  }
7
18
 
8
19
  /* https://gist.github.com/jeneg/9767afdcca45601ea44930ea03e0febf */
9
- Utilities.get = function(obj, path, def) {
20
+ Utilities.get = function (obj, path, def) {
10
21
  var fullPath = (path || '')
11
22
  .replace(/\[/g, '.')
12
23
  .replace(/]/g, '')
@@ -25,7 +36,7 @@ Utilities.get = function(obj, path, def) {
25
36
  }
26
37
 
27
38
  /* https://stackoverflow.com/questions/54733539/javascript-implementation-of-lodash-set-method */
28
- Utilities.set = function(obj, path, value) {
39
+ Utilities.set = function (obj, path, value) {
29
40
  if (Object(obj) !== obj) {
30
41
  return obj;
31
42
  }; // When obj is not an object
@@ -48,7 +59,7 @@ Utilities.set = function(obj, path, value) {
48
59
 
49
60
  // https://dzone.com/articles/cross-browser-javascript-copy-and-paste
50
61
  // https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f
51
- Utilities.clipboardCopy = function(input) {
62
+ Utilities.clipboardCopy = function (input) {
52
63
  var el = document.createElement('textarea');
53
64
  el.setAttribute('style','width:1px;border:0;opacity:0;');
54
65
  el.value = input && input.nodeType ? input.value || input.innerText || input.innerHTML : input;
@@ -62,4 +73,11 @@ Utilities.clipboardCopy = function(input) {
62
73
  document.body.removeChild(el);
63
74
  }
64
75
 
76
+ // Escape HTML
77
+ Utilities.escapeHTML = function (string) {
78
+ return string.replace(/[&<>"'`=\/]/g, function (s) {
79
+ return htmlEscapeMap[s];
80
+ });
81
+ }
82
+
65
83
  module.exports = Utilities;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.1.10",
3
+ "version": "3.1.11",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -28,4 +28,4 @@
28
28
  "firebase": "^8.10.1",
29
29
  "lazysizes": "^5.3.2"
30
30
  }
31
- }
31
+ }