Skip to content

Commit 363dcaf

Browse files
committed
handle incomplete github response
1 parent 33c88b9 commit 363dcaf

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/github.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ export async function getGithubUsersFromGithub(): Promise<Set<string>> {
3838

3939
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
4040
export function formatUserList(users): Set<string> {
41-
return new Set(users.map((user) => user?.login?.toLowerCase()))
41+
return new Set(
42+
users
43+
.map((user) => user.login?.toLowerCase())
44+
.flat()
45+
.filter(Boolean),
46+
)
4247
}
4348

4449
export async function getUserIdFromUsername(username: string): Promise<number> {

tests/github.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ describe('github integration', () => {
115115
})
116116

117117
it('formatUserList', () => {
118-
const response = [{ login: 'chrisns' }, { login: 'chrisns' }, { login: 'foo' }]
119-
118+
const response = [{ login: 'chrisns' }, { login: 'chrisns' }, { login: 'foo' }, {}]
120119
return expect(mod.formatUserList(response)).toEqual(new Set(['chrisns', 'foo']))
121120
})
122121
})

0 commit comments

Comments
 (0)