fix(striker-ui-api): remove excess from GET /host detail

main
Tsu-ba-me 2 years ago
parent 59ddc232e7
commit 884742cb0a
  1. 12
      striker-ui-api/src/lib/request_handlers/host/buildQueryHostDetail.ts

@ -1,5 +1,6 @@
import { buildKnownIDCondition } from '../../buildCondition'; import { buildKnownIDCondition } from '../../buildCondition';
import { buildQueryResultModifier } from '../../buildQueryResultModifier'; import { buildQueryResultModifier } from '../../buildQueryResultModifier';
import { cap } from '../../cap';
import { stdout } from '../../shell'; import { stdout } from '../../shell';
export const buildQueryHostDetail: BuildQueryDetailFunction = ({ export const buildQueryHostDetail: BuildQueryDetailFunction = ({
@ -28,8 +29,15 @@ export const buildQueryHostDetail: BuildQueryDetailFunction = ({
return output.reduce< return output.reduce<
{ hostName: string; hostUUID: string } & Record<string, string> { hostName: string; hostUUID: string } & Record<string, string>
>( >(
(previous, [, variableName, variableValue]) => { (previous, [, , variableName, variableValue]) => {
previous[variableName] = variableValue; const [, , variableKey] = variableName.split('::');
const [head, ...rest] = variableKey.split('_');
const key = rest.reduce<string>(
(previous, part) => `${previous}${cap(part)}`,
head,
);
previous[key] = variableValue;
return previous; return previous;
}, },

Loading…
Cancel
Save