Skip to content

Commit bbab5ac

Browse files
committed
fix(settings): array key is now sanitized
1 parent 1be3838 commit bbab5ac

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/utils/settings/types/array.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export default class ArrayType extends Text {
66
}
77

88
value(data) {
9-
if (Array.isArray(data)) return data;
10-
return JSON.parse(data);
9+
if (typeof data === 'string') return JSON.parse(data);
10+
return data;
1111
}
1212

1313
default() {
@@ -18,8 +18,10 @@ export default class ArrayType extends Text {
1818
key,
1919
container,
2020
}) {
21+
let index = 0;
2122
function add(text) {
22-
$(container).append(createArrayItem(text, key, value, update));
23+
$(container).append(createArrayItem(text, `${key}.${index}`, value, update));
24+
index += 1;
2325
}
2426
value.forEach(add);
2527
return $('<input type="text">').css({
@@ -42,8 +44,7 @@ export default class ArrayType extends Text {
4244
}
4345
}
4446

45-
function createArrayItem(text, skey, value, update) {
46-
const key = `${skey}.${text}`;
47+
function createArrayItem(text, key, value, update) {
4748
const ret = $('<div>')
4849
.on('change.script', () => {
4950
const i = value.indexOf(text);

0 commit comments

Comments
 (0)