From 5ddb689ff9524b33277ffb6031ac8e04e27ca498 Mon Sep 17 00:00:00 2001 From: IDCs Date: Thu, 9 Nov 2023 08:37:10 +0000 Subject: [PATCH] added gamestore helper input validation --- src/util/GameStoreHelper.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/util/GameStoreHelper.ts b/src/util/GameStoreHelper.ts index f61a0af32..116df4645 100644 --- a/src/util/GameStoreHelper.ts +++ b/src/util/GameStoreHelper.ts @@ -146,11 +146,15 @@ class GameStoreHelper { }); public findByName(name: string | string[], storeId?: string): Bluebird { - return this.findGameEntry('name', name, storeId); + return this.validInput(name) + ? this.findGameEntry('name', name, storeId) + : Bluebird.reject(new GameEntryNotFound('Invalid name input', this.mStores.map(store => store.id).join(', '))); } public findByAppId(appId: string | string[], storeId?: string): Bluebird { - return this.findGameEntry('id', appId, storeId); + return this.validInput(appId) + ? this.findGameEntry('id', appId, storeId) + : Bluebird.reject(new GameEntryNotFound('Invalid appId input', this.mStores.map(store => store.id).join(', '))); } public launchGameStore(api: IExtensionApi, gameStoreId: string, @@ -289,6 +293,10 @@ class GameStoreHelper { (exeId === runningProc.exeFile.toLowerCase())) !== undefined; } + private validInput(input: string | string[]): boolean { + return (!input || (Array.isArray(input) && input.length === 0)) ? false : true; + } + private getStores(): IGameStore[] { if (!!this.mStores) { return this.mStores;