@@ -51,7 +51,8 @@ export async function getGitRepositoryInfo(workspaceRoot: string): Promise<GitRe
5151
5252 if ( urlMatch && urlMatch [ 1 ] ) {
5353 const url = urlMatch [ 1 ] . trim ( )
54- gitInfo . repositoryUrl = sanitizeGitUrl ( url )
54+ // Sanitize the URL and convert to HTTPS format for telemetry
55+ gitInfo . repositoryUrl = convertGitUrlToHttps ( sanitizeGitUrl ( url ) )
5556 const repositoryName = extractRepositoryName ( url )
5657 if ( repositoryName ) {
5758 gitInfo . repositoryName = repositoryName
@@ -88,6 +89,49 @@ export async function getGitRepositoryInfo(workspaceRoot: string): Promise<GitRe
8889 }
8990}
9091
92+ /**
93+ * Sanitizes a git URL to remove sensitive information like tokens
94+ * @param url The original git URL
95+ * @returns Sanitized URL
96+ */
97+ /**
98+ * Converts a git URL to HTTPS format
99+ * @param url The git URL to convert
100+ * @returns The URL in HTTPS format, or the original URL if conversion is not possible
101+ */
102+ export function convertGitUrlToHttps ( url : string ) : string {
103+ try {
104+ // Already HTTPS, just return it
105+ if ( url . startsWith ( "https://" ) ) {
106+ return url
107+ }
108+
109+ // Handle SSH format: git@github .com:user/repo.git -> https://github.com/user/repo.git
110+ if ( url . startsWith ( "git@" ) ) {
111+ const match = url . match ( / g i t @ ( [ ^ : ] + ) : ( .+ ) / )
112+ if ( match && match . length === 3 ) {
113+ const [ , host , path ] = match
114+ return `https://${ host } /${ path } `
115+ }
116+ }
117+
118+ // Handle SSH with protocol: ssh://git@github .com/user/repo.git -> https://github.com/user/repo.git
119+ if ( url . startsWith ( "ssh://" ) ) {
120+ const match = url . match ( / s s h : \/ \/ (?: g i t @ ) ? ( [ ^ \/ ] + ) \/ ( .+ ) / )
121+ if ( match && match . length === 3 ) {
122+ const [ , host , path ] = match
123+ return `https://${ host } /${ path } `
124+ }
125+ }
126+
127+ // Return original URL if we can't convert it
128+ return url
129+ } catch {
130+ // If parsing fails, return original
131+ return url
132+ }
133+ }
134+
91135/**
92136 * Sanitizes a git URL to remove sensitive information like tokens
93137 * @param url The original git URL
0 commit comments