From dc6eb4a6d2e10ce4bbd8d7ea9c7387e8ab3b7d62 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Fri, 5 May 2023 14:04:11 -0400 Subject: [PATCH] fix(striker-ui-api): correct hex regexp pattern --- striker-ui-api/src/lib/consts/REG_EXP_PATTERNS.ts | 2 +- .../lib/request_handlers/server/getServerDetail.ts | 13 ++++++++++--- striker-ui-api/src/types/ApiServer.d.ts | 9 +++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/striker-ui-api/src/lib/consts/REG_EXP_PATTERNS.ts b/striker-ui-api/src/lib/consts/REG_EXP_PATTERNS.ts index c62557a6..d16e72e3 100644 --- a/striker-ui-api/src/lib/consts/REG_EXP_PATTERNS.ts +++ b/striker-ui-api/src/lib/consts/REG_EXP_PATTERNS.ts @@ -1,4 +1,4 @@ -export const P_HEX = '[[:xdigit:]]'; +export const P_HEX = '[a-f0-9]'; export const P_OCTET = '(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9]|)[0-9])'; export const P_ALPHANUM = '[a-z0-9]'; export const P_ALPHANUM_DASH = '[a-z0-9-]'; diff --git a/striker-ui-api/src/lib/request_handlers/server/getServerDetail.ts b/striker-ui-api/src/lib/request_handlers/server/getServerDetail.ts index befd04ef..faa16053 100644 --- a/striker-ui-api/src/lib/request_handlers/server/getServerDetail.ts +++ b/striker-ui-api/src/lib/request_handlers/server/getServerDetail.ts @@ -17,9 +17,16 @@ const rmfifo = (path: string) => { } }; -export const getServerDetail: RequestHandler = async (request, response) => { - const { serverUUID } = request.params; - const { ss, resize } = request.query; +export const getServerDetail: RequestHandler< + ServerDetailParamsDictionary, + unknown, + unknown, + ServerDetailParsedQs +> = async (request, response) => { + const { + params: { serverUUID }, + query: { ss, resize }, + } = request; const epoch = Date.now(); const isScreenshot = sanitize(ss, 'boolean'); diff --git a/striker-ui-api/src/types/ApiServer.d.ts b/striker-ui-api/src/types/ApiServer.d.ts index ece4a217..49f4c4e7 100644 --- a/striker-ui-api/src/types/ApiServer.d.ts +++ b/striker-ui-api/src/types/ApiServer.d.ts @@ -6,3 +6,12 @@ type ServerOverview = { serverState: string; serverUUID: string; }; + +type ServerDetailParamsDictionary = { + serverUUID: string; +}; + +type ServerDetailParsedQs = { + ss: boolean | number | string; + resize: string; +};