Skip to content

Commit

Permalink
fix: Update getTeam enemyTeam.id logic (#337)
Browse files Browse the repository at this point in the history
Currently, the `getTeam` endpoint throws an error:

```
Cannot read property 'split' of undefined
```

After a bit of digging, I found out that it was happening on this line: https://github.com/gigobyte/HLTV/blob/master/src/endpoints/getTeam.ts#L45

`popSlashSource` is looking for `.attr('src')` on an `img` that doesn't exist. Instead, `.team-row .team-2` is an `a` tag that has the team ID in its `href`, so I changed this line to parse the team ID from there.
  • Loading branch information
trevorblades authored Sep 17, 2020
1 parent e813d21 commit e35bd13
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/endpoints/getTeam.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { FullTeam, Result, Achievement } from '../models/FullTeam'
import { HLTVConfig } from '../config'
import { fetchPage, toArray } from '../utils/mappers'
import { popSlashSource } from '../utils/parsing'

export const getTeam = (config: HLTVConfig) => async ({
id
Expand Down Expand Up @@ -41,9 +40,7 @@ export const getTeam = (config: HLTVConfig) => async ({
.split('/')[2]
),
enemyTeam: {
id: Number(
popSlashSource(matchEl.find('.team-2 .team-logo-container img'))!
),
id: Number(matchEl.find('.team-2').attr('href').split('/')[2]),
name: matchEl.find('span.team-2').text()
},
result: matchEl.find('.score-cell').text()
Expand Down

0 comments on commit e35bd13

Please sign in to comment.