Skip to content

Commit

Permalink
fix: support /stars/user in GitHub cards
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jan 3, 2023
1 parent f8703fc commit d353f38
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions components/status/StatusPreviewGitHub.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,24 @@ interface Meta {
}
}
const specialRoutes = ['orgs', 'sponsors', 'stars']
const meta = $computed(() => {
const { url } = props.card
const path = url.split('https://github.com/')[1]
// Supported paths
// /user
// /user/repo
// /user/repo/issues/number.*
// /user/repo/pull/number.*
// /orgs/user.*
// /user/repo/issues/number
// /user/repo/pull/number
// /orgs/user
// /sponsors/user
// /stars/user
const firstName = path.match(/([\w-]+)(\/|$)/)?.[1]
const secondName = path.match(/[\w-]+\/([\w-]+)/)?.[1]
const firstIsUser = firstName !== 'orgs' && firstName !== 'sponsors'
const firstIsUser = firstName && !specialRoutes.includes(firstName)
const user = firstIsUser ? firstName : secondName
const repo = firstIsUser ? secondName : undefined
Expand Down

0 comments on commit d353f38

Please sign in to comment.