mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-18 06:22:28 +03:00
fix: Update cleanUrl method to handle ssh URLs
This commit is contained in:
parent
647cbb3cac
commit
038dba6710
@ -381,6 +381,13 @@ export class BaseBranch {
|
|||||||
private cleanUrl(url: string): string {
|
private cleanUrl(url: string): string {
|
||||||
if (url.startsWith('http')) {
|
if (url.startsWith('http')) {
|
||||||
return url.replace('.git', '').trim();
|
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 {
|
} else {
|
||||||
return url.replace(':', '/').replace('git@', 'https://').replace('.git', '').trim();
|
return url.replace(':', '/').replace('git@', 'https://').replace('.git', '').trim();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user