yelda-webchat 1.1.18 → 1.1.20
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/dist/js/yeldaWebchatInjector.js +2 -2
- package/dist/js/yeldaWebchatInjector.js.gz +0 -0
- package/dist/js/yeldaWebchatInjector.js.map +1 -1
- package/dist/js/yeldaWebchatInjector.min.js +2 -2
- package/dist/js/yeldaWebchatInjector.min.js.gz +0 -0
- package/dist/js/yeldaWebchatInjector.min.js.map +1 -1
- package/package.json +3 -3
- package/src/js/yeldaWebchatInjector.js +25 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yelda-webchat",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.20",
|
|
4
4
|
"description": "Website Chat Plugin",
|
|
5
5
|
"main": "./dist/js/yeldaWebchatInjector.min.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"autoprefixer-loader": "^3.2.0",
|
|
28
28
|
"aws-sdk": "^2.732.0",
|
|
29
29
|
"babel-core": "^6.26.3",
|
|
30
|
-
"babel-eslint": "^
|
|
30
|
+
"babel-eslint": "^10.1.0",
|
|
31
31
|
"babel-loader": "^7.1.5",
|
|
32
32
|
"babel-plugin-transform-runtime": "^6.23.0",
|
|
33
33
|
"babel-preset-env": "^1.7.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"extract-text-webpack-plugin": "^3.0.2",
|
|
45
45
|
"file-loader": "^1.1.11",
|
|
46
46
|
"inject-loader": "^4.0.1",
|
|
47
|
-
"jsdom": "^
|
|
47
|
+
"jsdom": "^16.5.0",
|
|
48
48
|
"less": "^3.10.3",
|
|
49
49
|
"less-loader": "^4.1.0",
|
|
50
50
|
"mime": "^2.4.6",
|
|
@@ -14,17 +14,32 @@ import config from '../config'
|
|
|
14
14
|
* @returns {Boolean}
|
|
15
15
|
*/
|
|
16
16
|
const isStrLikelyEncoded = (str) => {
|
|
17
|
-
// Check if the string contains any characters that would typically need encoding
|
|
18
|
-
const needsEncoding = /[?&=<>#%{}|\\\^~\[\]`;"\s]/.test(str)
|
|
19
|
-
|
|
20
17
|
// Check if the string contains any non-ASCII characters
|
|
18
|
+
// eslint-disable-next-line no-control-regex
|
|
21
19
|
const hasNonASCII = /[^\x00-\x7F]/.test(str);
|
|
22
20
|
|
|
23
21
|
// Check if the string contains any percent-encoded characters
|
|
24
22
|
const hasPercentEncoding = /%[0-9A-Fa-f]{2}/.test(str)
|
|
25
23
|
|
|
26
24
|
// Return true if any of the conditions are met
|
|
27
|
-
return
|
|
25
|
+
return hasNonASCII || hasPercentEncoding
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Check whether the string is stringified object
|
|
30
|
+
* @param {String} str
|
|
31
|
+
* @returns {Boolean}
|
|
32
|
+
*/
|
|
33
|
+
const isStringifiedObject = (str) => {
|
|
34
|
+
try {
|
|
35
|
+
// Replace single quotes with double quotes
|
|
36
|
+
const jsonString = str.replace(/'/g, '"')
|
|
37
|
+
// Attempt to parse the string
|
|
38
|
+
const obj = JSON.parse(jsonString)
|
|
39
|
+
return typeof obj === 'object' && obj !== null
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return false // Parsing failed, not a valid JSON string
|
|
42
|
+
}
|
|
28
43
|
}
|
|
29
44
|
|
|
30
45
|
/**
|
|
@@ -112,6 +127,12 @@ class YeldaChat {
|
|
|
112
127
|
} catch(err) {
|
|
113
128
|
return ''
|
|
114
129
|
}
|
|
130
|
+
} else if (isStringifiedObject(arg)) {
|
|
131
|
+
try{
|
|
132
|
+
return JSON.parse(arg.replace(/'/g, '"'))
|
|
133
|
+
} catch(err) {
|
|
134
|
+
return ''
|
|
135
|
+
}
|
|
115
136
|
}
|
|
116
137
|
return arg.replace(/^['"]|['"]$/g, '') // Remove surrounding quotes if any
|
|
117
138
|
})
|