Skip to content

Commit fd34e8e

Browse files
committed
update
1 parent 13c57d3 commit fd34e8e

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/configuration/apiCommunicationUtils.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,16 @@ function normalizeTopic(
3131
return [{ value: '' }];
3232
}
3333

34+
const getTopicValue = (t: { value?: string; type?: string; _?: string }): string =>
35+
typeof t._ === 'string' ? t._ :
36+
typeof t.value === 'string' ? t.value :
37+
typeof t.type === 'string' ? t.type :
38+
'';
39+
3440
if (Array.isArray(topic)) {
35-
const normalized = topic.map((t): Topic => ({
36-
value: typeof t._ === 'string' ? t._ :
37-
typeof t.value === 'string' ? t.value :
38-
typeof t.type === 'string' ? t.type :
39-
''
40-
}));
41-
41+
const normalized = topic.map((t): Topic => ({ value: getTopicValue(t) }));
4242
return normalized.length > 0 ? [normalized[0]] : [{ value: '' }];
4343
}
4444

45-
return [{
46-
value: typeof topic._ === 'string' ? topic._ :
47-
typeof topic.value === 'string' ? topic.value :
48-
typeof topic.type === 'string' ? topic.type :
49-
''
50-
}];
45+
return [{ value: getTopicValue(topic) }];
5146
}

0 commit comments

Comments
 (0)