web-manager 3.1.9 → 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.
- package/lib/dom.js +5 -3
- package/lib/utilities.js +21 -3
- package/package.json +1 -1
package/lib/dom.js
CHANGED
@@ -257,9 +257,11 @@ Dom.loadScript = function(options, callback) {
|
|
257
257
|
options.cacheBreaker = typeof options.cacheBreaker === 'undefined' ? true : options.cacheBreaker;
|
258
258
|
|
259
259
|
if (options.cacheBreaker) {
|
260
|
-
|
261
|
-
|
262
|
-
|
260
|
+
var src = options.src.split('?');
|
261
|
+
var query = new URLSearchParams(src[1])
|
262
|
+
query.set('cb', new Date().getTime());
|
263
|
+
|
264
|
+
options.src = src[0] + '?' + query.toString();
|
263
265
|
}
|
264
266
|
|
265
267
|
var s = document.createElement('script');
|
package/lib/utilities.js
CHANGED
@@ -1,12 +1,23 @@
|
|
1
1
|
/*
|
2
2
|
*/
|
3
3
|
|
4
|
+
var htmlEscapeMap = {
|
5
|
+
'&': '&',
|
6
|
+
'<': '<',
|
7
|
+
'>': '>',
|
8
|
+
'"': '"',
|
9
|
+
"'": ''',
|
10
|
+
'/': '/',
|
11
|
+
'`': '`',
|
12
|
+
'=': '='
|
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