@@ -293,33 +293,15 @@ const providers: ProviderConfig[] = [
293293 * Handles: git+https://, git://, git@host:path, ssh://git@host/path
294294 */
295295export function normalizeGitUrl ( input : string ) : string | null {
296- const raw = input . trim ( )
297- if ( ! raw ) return null
298-
299- const normalized = raw . replace ( / ^ g i t \+ / , '' )
300-
301- // Handle ssh:// and git:// URLs by converting to https://
302- if ( / ^ (?: s s h | g i t ) : \/ \/ / i. test ( normalized ) ) {
303- try {
304- const url = new URL ( normalized )
305- const path = url . pathname . replace ( / ^ \/ * / , '' )
306- return `https://${ url . hostname } /${ path } `
307- } catch {
308- // Fall through to SCP handling
309- }
310- }
311-
312- if ( ! / ^ h t t p s ? : \/ \/ / i. test ( normalized ) ) {
313- // Handle SCP-style URLs: git@host:path
314- const scp = normalized . match ( / ^ (?: g i t @ ) ? ( [ ^ : / ] + ) : ( .+ ) $ / i)
315- if ( scp ?. [ 1 ] && scp ?. [ 2 ] ) {
316- const host = scp [ 1 ]
317- const path = scp [ 2 ] . replace ( / ^ \/ * / , '' )
318- return `https://${ host } /${ path } `
319- }
320- }
321-
322- return normalized
296+ const normalized = input
297+ . trim ( )
298+ . replace ( / ^ g i t \+ / , '' )
299+ . replace ( / \. g i t $ / , '' )
300+ . replace ( / ( ^ | \/ ) [ ^ / ] + ?@ / , '$1' ) // remove "user@" from "ssh://user@host.com:..."
301+ . replace ( / ( \. [ ^ . ] + ?) : / , '$1/' ) // change ".com:" to ".com/" from "ssh://user@host.com:..."
302+ . replace ( / ^ g i t : \/ \/ / , 'https://' )
303+ . replace ( / ^ s s h : \/ \/ / , 'https://' )
304+ return normalized || null
323305}
324306
325307export function parseRepoUrl ( input : string ) : RepoRef | null {
0 commit comments