From d353f38ac926121c532f46d0c436c147766848eb Mon Sep 17 00:00:00 2001 From: patak Date: Tue, 3 Jan 2023 16:59:49 +0100 Subject: [PATCH] fix: support /stars/user in GitHub cards --- components/status/StatusPreviewGitHub.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/status/StatusPreviewGitHub.vue b/components/status/StatusPreviewGitHub.vue index 5d0da480..b8f3e7a1 100644 --- a/components/status/StatusPreviewGitHub.vue +++ b/components/status/StatusPreviewGitHub.vue @@ -20,6 +20,8 @@ interface Meta { } } +const specialRoutes = ['orgs', 'sponsors', 'stars'] + const meta = $computed(() => { const { url } = props.card const path = url.split('https://github.com/')[1] @@ -27,13 +29,15 @@ const meta = $computed(() => { // 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