Skip to content

Commit 969b536

Browse files
authored
Merge pull request #446
fix(hotfix): Prevent misdesigned subscriptions to be always treated as array * fix(hotfix): prevent bug with non-array subscriptions * chore(hotfix): fix coverage
1 parent 65ab68b commit 969b536

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

hivemq-edge/src/frontend/src/modules/Workspace/utils/topics-utils.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,14 @@ const getTopicsFromPath = (path: string, instance: RJSFSchema): string[] => {
6767
if (property === TOPIC_PATH_ITEMS_TOKEN) {
6868
const res: string[] = []
6969

70-
for (const item of instance as RJSFSchema[]) {
71-
const topicsFromPath = getTopicsFromPath(rest.join('.'), item)
70+
/* istanbul ignore else -- @preserve */
71+
if (Array.isArray(instance)) {
72+
for (const item of instance as RJSFSchema[]) {
73+
const topicsFromPath = getTopicsFromPath(rest.join('.'), item)
74+
res.push(...topicsFromPath)
75+
}
76+
} else {
77+
const topicsFromPath = getTopicsFromPath(rest.join('.'), instance as RJSFSchema)
7278
res.push(...topicsFromPath)
7379
}
7480
return res
@@ -107,6 +113,7 @@ export const mergeAllTopics = (
107113
if (adapters) {
108114
const adapterTopics = adapters.reduce<string[]>((acc, cur) => {
109115
const type = types?.items?.find((e) => e.id === cur.type)
116+
/* istanbul ignore next -- @preserve */
110117
if (!type) return acc
111118
const topics = discoverAdapterTopics(type, cur.config as GenericObjectType)
112119
acc.push(...topics)

0 commit comments

Comments
 (0)