yelda-webchat 1.1.20 → 1.1.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yelda-webchat",
3
- "version": "1.1.20",
3
+ "version": "1.1.21",
4
4
  "description": "Website Chat Plugin",
5
5
  "main": "./dist/js/yeldaWebchatInjector.min.js",
6
6
  "license": "MIT",
@@ -95,11 +95,19 @@ class YeldaChat {
95
95
  if (argsStr !== '') {
96
96
  let argBuffer = ''
97
97
  let parenCount = 0
98
+ const openingBrackets = ['(', '[', '{']
99
+ const closingBrackets = [')', ']', '}']
100
+ let isQuotesOpened = false
101
+
98
102
  for (const element of argsStr) {
99
- if (element === '(') parenCount++
100
- else if (element === ')') parenCount--
103
+ if (element === `'`) {
104
+ isQuotesOpened = !isQuotesOpened
105
+ }
106
+
107
+ if (openingBrackets.includes(element)) parenCount++
108
+ else if(closingBrackets.includes(element)) parenCount--
101
109
 
102
- if (element === ',' && parenCount === 0) {
110
+ if (element === ',' && parenCount === 0 && !isQuotesOpened) {
103
111
  args.push(argBuffer.trim())
104
112
  argBuffer = ''
105
113
  } else {
@@ -117,7 +125,7 @@ class YeldaChat {
117
125
  else if (arg === 'null') return null
118
126
  else if (arg.startsWith('[') && arg.endsWith(']')) {
119
127
  try {
120
- return JSON.parse(arg)
128
+ return JSON.parse(JSON.stringify(arg))
121
129
  } catch(err) {
122
130
  return ''
123
131
  }