Skip to content

Commit

Permalink
fix type issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradgarropy committed Dec 4, 2023
1 parent d30e981 commit 21e6412
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/test-utils/mocks/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ const mockGitHubSponsorsResponse = {
isOneTime: true,
},
},
{
sponsorEntity: {
login: "romangarropy",
url: "https://github.com/romangarropy",
avatarUrl: "https://github.com/romangarropy.png",
},
tier: {
name: "$1000",
description: "Invalid sponsorship tier",
isOneTime: false,
},
},
],
},
},
Expand Down
12 changes: 9 additions & 3 deletions src/utils/sponsors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,20 @@ const getSponsors = async (): Promise<Sponsors> => {
const sponsorships = user.sponsorshipsAsMaintainer.nodes

sponsorships.forEach(sponsorship => {
const re = new RegExp("### (.*)$", "m")
const tier = re.exec(sponsorship.tier.description)[1].split(" ")[0]
const re = new RegExp("### (?<tier>.*)$", "m")
const tier = re.exec(sponsorship.tier.description)?.groups?.tier

if (!tier) {
return
}

const tierIcon = tier.split(" ")[0]

const sponsor: Sponsor = {
username: sponsorship.sponsorEntity.login,
avatar: sponsorship.sponsorEntity.avatarUrl,
profile: sponsorship.sponsorEntity.url,
tier,
tier: tierIcon,
}

if (sponsorship.tier.isOneTime) {
Expand Down

0 comments on commit 21e6412

Please sign in to comment.