From 884742cb0a392932fb49101770633ce695d693bc Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Mon, 7 Nov 2022 16:57:02 -0500 Subject: [PATCH] fix(striker-ui-api): remove excess from GET /host detail --- .../request_handlers/host/buildQueryHostDetail.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/striker-ui-api/src/lib/request_handlers/host/buildQueryHostDetail.ts b/striker-ui-api/src/lib/request_handlers/host/buildQueryHostDetail.ts index bbc72009..aa235463 100644 --- a/striker-ui-api/src/lib/request_handlers/host/buildQueryHostDetail.ts +++ b/striker-ui-api/src/lib/request_handlers/host/buildQueryHostDetail.ts @@ -1,5 +1,6 @@ import { buildKnownIDCondition } from '../../buildCondition'; import { buildQueryResultModifier } from '../../buildQueryResultModifier'; +import { cap } from '../../cap'; import { stdout } from '../../shell'; export const buildQueryHostDetail: BuildQueryDetailFunction = ({ @@ -28,8 +29,15 @@ export const buildQueryHostDetail: BuildQueryDetailFunction = ({ return output.reduce< { hostName: string; hostUUID: string } & Record >( - (previous, [, variableName, variableValue]) => { - previous[variableName] = variableValue; + (previous, [, , variableName, variableValue]) => { + const [, , variableKey] = variableName.split('::'); + const [head, ...rest] = variableKey.split('_'); + const key = rest.reduce( + (previous, part) => `${previous}${cap(part)}`, + head, + ); + + previous[key] = variableValue; return previous; },