Throw error for unknown hiscores CSV format

This commit is contained in:
molo-pl
2022-01-04 23:03:52 +01:00
parent 8737b50a82
commit f98cf8aaaa
3 changed files with 20 additions and 2 deletions

View File

@@ -27,7 +27,8 @@ import {
rsnFromElement,
getActivityPageURL,
httpGet,
BOSSES
BOSSES,
INVALID_FORMAT_ERROR
} from './utils';
/**
@@ -74,6 +75,10 @@ export function parseStats(csv: string): Stats {
.filter((entry) => !!entry)
.map((stat) => stat.split(','));
if (splitCSV.length !== SKILLS.length + BH_MODES.length + CLUES.length + BOSSES.length + 3) {
throw Error(INVALID_FORMAT_ERROR);
}
const skillObjects: Skill[] = splitCSV
.filter((stat) => stat.length === 3)
.map((stat) => {

View File

@@ -245,3 +245,5 @@ export const FORMATTED_BH_NAMES: FormattedBHNames = {
export const FORMATTED_LMS = 'Last Man Standing';
export const FORMATTED_SOUL_WARS = 'Soul Wars Zeal';
export const FORMATTED_LEAGUE_POINTS = 'League Points';
export const INVALID_FORMAT_ERROR = 'Invalid hiscores format';