Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added gamestore helper input validation #14878

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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