From 038dba67100cbff2f2b38a72a9448c49e7a84711 Mon Sep 17 00:00:00 2001 From: lisiur Date: Wed, 22 May 2024 14:43:25 +0800 Subject: [PATCH] fix: Update cleanUrl method to handle ssh URLs --- app/src/lib/vbranches/types.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/lib/vbranches/types.ts b/app/src/lib/vbranches/types.ts index 8f7bed67c..e232a1938 100644 --- a/app/src/lib/vbranches/types.ts +++ b/app/src/lib/vbranches/types.ts @@ -381,6 +381,13 @@ export class BaseBranch { private cleanUrl(url: string): string { if (url.startsWith('http')) { return url.replace('.git', '').trim(); + } else if (url.startsWith('ssh')) { + url = url.replace('ssh://git@', ''); + const [host, ...paths] = url.split('/'); + const path = paths.join('/').replace('.git', ''); + const protocol = /\d+\.\d+\.\d+\.\d+/.test(host) ? 'http' : 'https'; + const [hostname, _port] = host.split(':'); + return `${protocol}://${hostname}/${path}` } else { return url.replace(':', '/').replace('git@', 'https://').replace('.git', '').trim(); }