diff --git a/striker-ui-api/src/lib/request_handlers/fence/getFence.ts b/striker-ui-api/src/lib/request_handlers/fence/getFence.ts index 80570a23..b5894cdf 100644 --- a/striker-ui-api/src/lib/request_handlers/fence/getFence.ts +++ b/striker-ui-api/src/lib/request_handlers/fence/getFence.ts @@ -20,16 +20,33 @@ export const getFence: RequestHandler = buildGetRequestHandler( const afterQueryReturn: QueryResultModifierFunction | undefined = buildQueryResultReducer<{ [fenceUUID: string]: FenceOverview }>( - (previous, [fenceUUID, fenceName, fenceAgent, fenceArgumentString]) => { - const fenceParameters = fenceArgumentString - .split(/\s+/) - .reduce((previous, parameterPair) => { - const [parameterId, parameterValue] = parameterPair.split(/=/); + ( + previous, + [fenceUUID, fenceName, fenceAgent, fenceParametersString], + ) => { + const fenceParametersArray = fenceParametersString.match( + /(?:[^\s'"]+|'[^']*'|"[^"]*")+/g, + ); + + if (!fenceParametersArray) return previous; + + const fenceParameters = fenceParametersArray.reduce( + (previousParameters, parameterString) => { + const parameterPair = parameterString.split(/=(.*)/, 2); - previous[parameterId] = parameterValue.replace(/['"]/g, ''); + if (parameterPair.length !== 2) return previousParameters; - return previous; - }, {}); + const [parameterId, parameterValue] = parameterPair; + + previousParameters[parameterId] = parameterValue.replace( + /['"]/g, + '', + ); + + return previousParameters; + }, + {}, + ); stdout( `${fenceAgent}: ${fenceName} (${fenceUUID})\n${JSON.stringify(