From 236159007510ee32298f6022c07dde8ff57d76a5 Mon Sep 17 00:00:00 2001 From: casperiv0 <53900565+casperiv0@users.noreply.github.com> Date: Mon, 17 Jun 2024 08:16:44 +0200 Subject: [PATCH] fix: support additional tiles (closes #1947) --- .../admin/manage/cad-settings/live-map-controller.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/apps/api/src/controllers/admin/manage/cad-settings/live-map-controller.ts b/apps/api/src/controllers/admin/manage/cad-settings/live-map-controller.ts index 10f18a469..c362fb03b 100644 --- a/apps/api/src/controllers/admin/manage/cad-settings/live-map-controller.ts +++ b/apps/api/src/controllers/admin/manage/cad-settings/live-map-controller.ts @@ -71,14 +71,7 @@ export class CADSettingsLiveMapController { permissions: [Permissions.ManageCADSettings], }) async updateLiveMapTiles(@MultipartFile("tiles") files: PlatformMulterFile[]) { - const allowedNames = [ - "minimap_sea_0_0", - "minimap_sea_0_1", - "minimap_sea_1_0", - "minimap_sea_1_1", - "minimap_sea_2_0", - "minimap_sea_2_1", - ]; + const allowedName = /minimap_sea_-?\d*(\.\d+)?_-?\d*(\.\d+)?/; if (!Array.isArray(files)) { throw new ExtendedBadRequest({ tiles: "Invalid files" }); @@ -90,7 +83,7 @@ export class CADSettingsLiveMapController { throw new ExtendedBadRequest({ tiles: "Invalid file type" }); } - if (!allowedNames.includes(file.originalname)) { + if (!allowedName.test(file.originalname)) { throw new ExtendedBadRequest({ tiles: "Invalid file name" }); }