Skip to content

TypeError: Cannot read properties of undefined (reading 'split') - getTeam.js #821

Description

@mavrick

team id: 12642
https://www.hltv.org/team/12642/rebels
node: 20.11.1
hltv: 3.5.0

\node_modules\hltv\lib\endpoints\getTeam.js:112
code: $('.team-country .flag').attrThen('src', function (x) { var _a; return (_a = x.split('/').pop()) === null || _a === void 0 ? void 0 : _a.split('.')[0]; })
^

TypeError: Cannot read properties of undefined (reading 'split')
at \node_modules\hltv\lib\endpoints\getTeam.js:112:114
at Object.attrThen (\node_modules\hltv\lib\scraper.js:39:20)
at \node_modules\hltv\lib\endpoints\getTeam.js:112:60
at step (\node_modules\hltv\lib\endpoints\getTeam.js:33:23)
at Object.next (\node_modules\hltv\lib\endpoints\getTeam.js:14:53)
at fulfilled (\node_modules\hltv\lib\endpoints\getTeam.js:5:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

potential fix:

${x}.split('/').pop()

casting x to a string or additional null check here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions