Skip to content

Commit

Permalink
added gamestore helper input validation
Browse files Browse the repository at this point in the history
  • Loading branch information
IDCs committed Nov 9, 2023
1 parent e2bbbfc commit 5ddb689
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/util/GameStoreHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,15 @@ class GameStoreHelper {
});

public findByName(name: string | string[], storeId?: string): Bluebird<IGameStoreEntry> {
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<IGameStoreEntry> {
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,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5ddb689

Please sign in to comment.