1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-12 20:09:59 +00:00

fix: handle missing user in github preview

This commit is contained in:
Daniel Roe 2022-12-19 12:29:16 +00:00
parent b8ec153244
commit c7e6e10cb5
No known key found for this signature in database
GPG key ID: 22D5008E4F5D9B55

View file

@ -8,7 +8,7 @@ const props = defineProps<{
type UrlType = 'user' | 'repo' | 'issue' | 'pull'
interface Meta {
type: UrlType
user: string
user?: string
titleUrl: string
avatar: string
details: string
@ -26,7 +26,7 @@ interface Meta {
const meta = $computed(() => {
const { url } = props.card
const path = url.split('https://github.com/')[1]
const user = path.match(/([\w-]+)\//)![1]
const user = path.match(/([\w-]+)\//)?.[1]
const repo = path.match(/[\w-]+\/([\w-]+)/)?.[1]
const repoPath = `${user}/${repo}`
const inRepoPath = path.split(`${repoPath}/`)?.[1]