Skip to content

Commit

Permalink
Update getMatch halfs split error for forfeited maps (#623)
Browse files Browse the repository at this point in the history
Closes #622

* Adds if statement for if the half stats exist since they do not when a team forfeits a map. If it doesn't exist, just default to 0 rounds on each half.
  • Loading branch information
dbalders authored Dec 10, 2022
1 parent 74803b8 commit 5963652
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/endpoints/getMatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,16 @@ function getMaps($: HLTVPage): MapResult[] {

if (!isNaN(team1TotalRounds) && !isNaN(team2TotalRounds)) {
const halfsString = mapEl.find('.results-center-half-score').trimText()!
const halfs = halfsString
.split(' ')
.map((x) => x.replace(/\(|\)|;/g, ''))
.map((half) => ({
team1Rounds: Number(half.split(':')[0]),
team2Rounds: Number(half.split(':')[1])
}))
let halfs = [{team1Rounds: 0, team2Rounds: 0}, {team1Rounds: 0, team2Rounds: 0}]
if (halfsString) {
halfs = halfsString
.split(' ')
.map((x) => x.replace(/\(|\)|;/g, ''))
.map((half) => ({
team1Rounds: Number(half.split(':')[0]),
team2Rounds: Number(half.split(':')[1])
}))
}

result = {
team1TotalRounds,
Expand Down

0 comments on commit 5963652

Please sign in to comment.