Skip to content

Commit

Permalink
fix: throw an error when parseGameCode is called for American games
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed Apr 13, 2023
1 parent 12816d1 commit f36900d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/other/parseGameCode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EU_GAME_CODE_REGEX, JP_GAME_CODE_REGEX, Region } from '../utils/constants';
import type { GameEU, GameJP, GameUS } from '../utils/interfaces';
import { EshopError } from '../utils/utils';

/**
* Parses the game code to extract the cross-region portion.
Expand All @@ -12,7 +13,10 @@ export const parseGameCode = (game: GameUS | GameEU | GameJP, region: Region): s
let codeParse: RegExpExecArray | null;

switch (region) {
default:
case Region.AMERICAS:
throw new EshopError(
'`parseGameCode` is not possible for American games as the Nintendo API does not provide enough information to deduce the game code.'
);
case Region.EUROPE:
codeParse = EU_GAME_CODE_REGEX.exec((game as GameEU).product_code_txt[0]);
break;
Expand Down

0 comments on commit f36900d

Please sign in to comment.