fix(striker-ui-api): allow direct destructure from match() result

main
Tsu-ba-me 2 years ago
parent e3d4c243b9
commit c023c08310
  1. 5
      striker-ui-api/src/lib/match.ts
  2. 3
      striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts

@ -0,0 +1,5 @@
export const match = (
value: string,
regexp: string | RegExp,
{ fallbackResult = [] }: { fallbackResult?: string[] } = {},
) => value.match(regexp) ?? fallbackResult;

@ -1,6 +1,7 @@
import { getAnvilData, getLocalHostUUID } from '../../accessModule';
import { buildUnknownIDCondition } from '../../buildCondition';
import buildGetRequestHandler from '../buildGetRequestHandler';
import { match } from '../../match';
const buildHostConnections = (
fromHostUUID: string,
@ -90,7 +91,7 @@ export const getHostConnection = buildGetRequestHandler(
queryStdout.forEach(
([ipAddressUUID, hostUUID, ipAddress, network]) => {
const [, networkType, rawNetworkNumber, rawNetworkLinkNumber] =
network.match(/^([^\s]+)(\d+)_[^\s]+(\d+)$/);
match(network, /^([^\s]+)(\d+)_[^\s]+(\d+)$/);
const connectionKey = getConnectionKey(hostUUID);
connections[connectionKey].inbound.ipAddress[ipAddress] = {

Loading…
Cancel
Save