From 84790999260abd5cdc4246d3f02ef012d0f56e37 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 17 Apr 2026 20:42:11 +0800 Subject: [PATCH] fix: simplify plugin market repo display --- .../dialog/PluginMarketSettingDialog.vue | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/components/dialog/PluginMarketSettingDialog.vue b/src/components/dialog/PluginMarketSettingDialog.vue index 105e6a5e..f8ee1fac 100644 --- a/src/components/dialog/PluginMarketSettingDialog.vue +++ b/src/components/dialog/PluginMarketSettingDialog.vue @@ -89,6 +89,24 @@ function cancelEdit() { editingUrl.value = '' } +function formatRepoDisplay(url: string) { + try { + const parsedUrl = new URL(url) + const pathSegments = parsedUrl.pathname.split('/').filter(Boolean) + + if ( + ['github.com', 'www.github.com', 'raw.githubusercontent.com'].includes(parsedUrl.hostname) + && pathSegments.length >= 2 + ) { + return `${pathSegments[0]}/${pathSegments[1].replace(/\.git$/, '')}` + } + } catch { + // Ignore malformed URLs and fall back to the original value. + } + + return url +} + function moveUp(index: number) { if (index === 0) return const temp = repoList.value[index] @@ -159,7 +177,7 @@ onMounted(() => { - {{ repo }} + {{ formatRepoDisplay(repo) }}