diff --git a/app/src/lib/utils/url.test.ts b/app/src/lib/utils/url.test.ts index 1dcefbf09..ec5ae7cc7 100644 --- a/app/src/lib/utils/url.test.ts +++ b/app/src/lib/utils/url.test.ts @@ -1,24 +1,28 @@ -import { cleanUrl } from '$lib/utils/url'; +import { convertRemoteToWebUrl } from '$lib/utils/url'; import { describe, expect, test } from 'vitest'; describe.concurrent('cleanUrl', () => { test('it should handle url starts with http(s)?', () => { - expect(cleanUrl('https://github.com/user/repo.git')).toEqual('https://github.com/user/repo'); + expect(convertRemoteToWebUrl('https://github.com/user/repo.git')).toEqual( + 'https://github.com/user/repo' + ); }); test('it should handle complete ssh url with domain name', () => { - expect(cleanUrl('ssh://git@github.com:22/user/repo.git')).toEqual( + expect(convertRemoteToWebUrl('ssh://git@github.com:22/user/repo.git')).toEqual( 'https://github.com/user/repo' ); }); test('it should handle complete ssh url with ip', () => { - expect(cleanUrl('ssh://git@192.168.1.1:22/user/repo.git')).toEqual( + expect(convertRemoteToWebUrl('ssh://git@192.168.1.1:22/user/repo.git')).toEqual( 'http://192.168.1.1/user/repo' ); }); test('it should handle SCP-like url', () => { - expect(cleanUrl('git@github.com:user/repo.git')).toEqual('https://github.com/user/repo'); + expect(convertRemoteToWebUrl('git@github.com:user/repo.git')).toEqual( + 'https://github.com/user/repo' + ); }); }); diff --git a/app/src/lib/utils/url.ts b/app/src/lib/utils/url.ts index d818f13f5..49078f53c 100644 --- a/app/src/lib/utils/url.ts +++ b/app/src/lib/utils/url.ts @@ -24,7 +24,7 @@ export function openExternalUrl(href: string) { } // turn a git remote url into a web url (github, gitlab, bitbucket, etc) -export function cleanUrl(url: string): string { +export function convertRemoteToWebUrl(url: string): string { if (url.startsWith('http')) { return url.replace('.git', '').trim(); } else if (url.startsWith('ssh')) { diff --git a/app/src/lib/vbranches/types.ts b/app/src/lib/vbranches/types.ts index 1235bfb2d..28f90549a 100644 --- a/app/src/lib/vbranches/types.ts +++ b/app/src/lib/vbranches/types.ts @@ -2,7 +2,7 @@ import 'reflect-metadata'; import { splitMessage } from '$lib/utils/commitMessage'; import { hashCode } from '$lib/utils/string'; import { isDefined, notNull } from '$lib/utils/typeguards'; -import { cleanUrl } from '$lib/utils/url'; +import { convertRemoteToWebUrl } from '$lib/utils/url'; import { Type, Transform } from 'class-transformer'; export type ChangeType = @@ -371,11 +371,11 @@ export class BaseBranch { } get pushRepoBaseUrl(): string { - return cleanUrl(this.pushRemoteUrl); + return convertRemoteToWebUrl(this.pushRemoteUrl); } get repoBaseUrl(): string { - return cleanUrl(this.remoteUrl); + return convertRemoteToWebUrl(this.remoteUrl); } commitUrl(commitId: string): string | undefined {